ron icon indicating copy to clipboard operation
ron copied to clipboard

Explore untagged enums

Open juntyr opened this issue 3 years ago • 2 comments

Experimentation for #253 and #397

  • [ ] I've included my change in CHANGELOG.md

juntyr avatar Sep 18 '22 14:09 juntyr

Codecov Report

Merging #409 (afb960b) into master (298f918) will decrease coverage by 0.49%. The diff coverage is 72.54%.

@@            Coverage Diff             @@
##           master     #409      +/-   ##
==========================================
- Coverage   79.81%   79.32%   -0.50%     
==========================================
  Files          54       55       +1     
  Lines        7080     7747     +667     
==========================================
+ Hits         5651     6145     +494     
- Misses       1429     1602     +173     
Impacted Files Coverage Δ
src/parse.rs 78.87% <ø> (-0.67%) :arrow_down:
src/ser/value.rs 23.07% <0.00%> (-26.93%) :arrow_down:
tests/289_enumerate_arrays.rs 100.00% <ø> (ø)
src/value/mod.rs 55.05% <32.14%> (-12.42%) :arrow_down:
src/de/mod.rs 77.00% <77.77%> (+0.97%) :arrow_up:
src/de/id.rs 20.20% <80.00%> (+4.50%) :arrow_up:
src/de/tests.rs 94.11% <100.00%> (+0.69%) :arrow_up:
src/de/value.rs 76.48% <100.00%> (+0.60%) :arrow_up:
tests/117_untagged_tuple_variant.rs 100.00% <100.00%> (ø)
tests/357_untagged_roundtrip.rs 100.00% <100.00%> (ø)
... and 6 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov-commenter avatar Sep 18 '22 14:09 codecov-commenter

@torkleyy This is mostly an old experiment that I just rebased, but I wanted to see what would need to be done to make this feel right. Essentially, we could land this change 'as-is' to support all serde enum shenanigans. While this might be an ok first step, it would change how our Value type works and tie it even more to json. Hence, I'm now experimenting a bit with whether this change could be done in combination with a more rony Value that has variants for structs (and tuples). Here are my findings so far:

  • since serialising requires &'static str for all struct and field names, the Value would need to use those as well. Hence, any deserialising would require some string interning (e.g. using https://github.com/CAD97/simple-interner which supports &'static str from rust 1.63 onwards)
  • structs without a name in ron will bite us - we can either reject deserialising them or reject serialising them since serde doesn't have that concept
  • so far treating structs like enums in ron seems to work fine

I think in the end this will come down to whether we want the ron::Value to be essentially a clone of serde_json::Value (easy to implement but no roundtrips) or reflect ron more (more work). Any thoughts?

juntyr avatar Sep 18 '22 16:09 juntyr

Superseded by #451

juntyr avatar May 01 '23 10:05 juntyr