ron-rs / ron

Rusty Object Notation
https://docs.rs/ron
Apache License 2.0
3.31k stars 122 forks source link

Fix raw value constructor vs de parsing incompatibility #487

Closed juntyr closed 1 year ago

juntyr commented 1 year ago
juntyr commented 1 year ago

@torkleyy This is quite an annoying bug and I am not sure if this is the right way forward to fix it. The problem is that RawValue will have to be annoying in one of two ways:

a) RawValue::from_ron("/*hi*/ 42 /*bye*/") works as expected (i.e. any valid ron, except for attributes, can be used in the constructor and will be pasted literally into the output). However, deserialising only roundtrips if no pretty serialising is used since any pretty whitespace or comments will be eaten up by the raw value upon the next deserialising. I'm going with this option right now.

b) RawValue::from_ron("/*hi*/ ( /*yay*/ 42 /*lol*/ ) /*bye*/") only keeps ( /*yay*/ 42 /*lol*/ ) (so all whitespace before and after the first non-whitespace is lost), but roundtripping works since additional pretty whitespace is dropped.

Which one would you prefer?

codecov-commenter commented 1 year ago

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.04% :tada:

Comparison is base (a293382) 95.27% compared to head (6abc432) 95.32%.

:exclamation: Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #487 +/- ## ========================================== + Coverage 95.27% 95.32% +0.04% ========================================== Files 74 74 Lines 8852 8936 +84 ========================================== + Hits 8434 8518 +84 Misses 418 418 ``` | [Files Changed](https://app.codecov.io/gh/ron-rs/ron/pull/487?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None) | Coverage Δ | | |---|---|---| | [src/de/mod.rs](https://app.codecov.io/gh/ron-rs/ron/pull/487?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2RlL21vZC5ycw==) | `96.57% <100.00%> (+0.01%)` | :arrow_up: | | [src/de/tests.rs](https://app.codecov.io/gh/ron-rs/ron/pull/487?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL2RlL3Rlc3RzLnJz) | `100.00% <100.00%> (ø)` | | | [src/parse.rs](https://app.codecov.io/gh/ron-rs/ron/pull/487?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL3BhcnNlLnJz) | `96.62% <100.00%> (+0.01%)` | :arrow_up: | | [src/ser/mod.rs](https://app.codecov.io/gh/ron-rs/ron/pull/487?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL3Nlci9tb2QucnM=) | `96.61% <100.00%> (+0.01%)` | :arrow_up: | | [src/value/raw.rs](https://app.codecov.io/gh/ron-rs/ron/pull/487?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-c3JjL3ZhbHVlL3Jhdy5ycw==) | `100.00% <100.00%> (ø)` | | | [tests/407\_raw\_value.rs](https://app.codecov.io/gh/ron-rs/ron/pull/487?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-dGVzdHMvNDA3X3Jhd192YWx1ZS5ycw==) | `100.00% <100.00%> (ø)` | | | [tests/481\_number\_underscores\_suffixes.rs](https://app.codecov.io/gh/ron-rs/ron/pull/487?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=None#diff-dGVzdHMvNDgxX251bWJlcl91bmRlcnNjb3Jlc19zdWZmaXhlcy5ycw==) | `99.81% <100.00%> (+0.01%)` | :arrow_up: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

torkleyy commented 1 year ago

Approach a seems like the better one, yeah.