Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explore untagged enums #409

Closed
wants to merge 6 commits into from
Closed

Conversation

juntyr
Copy link
Member

@juntyr juntyr commented Sep 18, 2022

Experimentation for #253 and #397

  • I've included my change in CHANGELOG.md

@codecov-commenter
Copy link

codecov-commenter commented Sep 18, 2022

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%) ⬇️
src/ser/value.rs 23.07% <0.00%> (-26.93%) ⬇️
tests/289_enumerate_arrays.rs 100.00% <ø> (ø)
src/value/mod.rs 55.05% <32.14%> (-12.42%) ⬇️
src/de/mod.rs 77.00% <77.77%> (+0.97%) ⬆️
src/de/id.rs 20.20% <80.00%> (+4.50%) ⬆️
src/de/tests.rs 94.11% <100.00%> (+0.69%) ⬆️
src/de/value.rs 76.48% <100.00%> (+0.60%) ⬆️
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.

@juntyr
Copy link
Member Author

juntyr commented Sep 18, 2022

@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
Copy link
Member Author

juntyr commented May 1, 2023

Superseded by #451

@juntyr juntyr closed this May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants