-
Notifications
You must be signed in to change notification settings - Fork 125
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
Add number suffixes and allow more number underscores #481
Conversation
Codecov ReportPatch coverage:
❗ 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@@ Coverage Diff @@
## master #481 +/- ##
==========================================
+ Coverage 82.95% 84.02% +1.07%
==========================================
Files 74 75 +1
Lines 9267 10035 +768
==========================================
+ Hits 7687 8432 +745
- Misses 1580 1603 +23
☔ View full report in Codecov by Sentry. |
Manually checking the coverage shows that 100% of the patch seems to be covered |
4b4d20a
to
c6622b2
Compare
One interesting detail for the future is that:
If we don't want this behaviour (in a future where roundtripping through |
Fixes #241
This PR implements optional number type suffixes, which can be turned on with the
PrettyConfig::number_suffixes
option and are allowed during parsing. To allow Rusty suffixes to work with floating literals, this PR also finally allows using underscores in float literals, using the Rust syntax as a reference.This PR turned out to be significantly more work than I had anticipated. In particular, a number which could fit into the destination type, e.g.
1_u8
, now has to reject when deserialising into a typedu16
, since the type is an explicit mismatch. I tried my best to keep the changes in parsing small-ish and to use this opportunity to improve some error reporting a bit.For users of RON, this should be an unobservable change (apart from some error code changes which are now more meaningful). However, writing RON files can now be a bit more Rusty as types can be encoded explicitly and underscores can be used to make (long) number literals more readable. However, anyone serialising RON data should probably not turn the
PrettyConfig::number_suffixes
flag on unless they need lossless roundtrips throughValue::Number
variants, since explicit typing makes it harder to upgrade a format to different number types without breaking compatibility.CHANGELOG.md