You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Supersedes #403, #453, and #454 to add minimal support for #[serde(flatten)] in RON. Instead of many workarounds to make flattened structs serialise into nice RON struct syntax and deserialise from them, both of which are really difficult since serde gives us no information to work with and just delegates to map serialisation/deserialisation, this PR just ensures that at least flattened structs can roundtrip through RON.
For this, just one hack is necessary. If we detect that a map is deserialised into what looks like a struct (thanks @clouds56 for contributing the detection in #454), we enforce that map key identifiers are actually strings written exactly as ", identifier, ". This seems to be enough to get the tests to work that I initially designed for #403.
@torkleyy I'd be in favour of landing this instead of going down the rabbit hole of #403 since that just fixes one of the two parts and getting flattened structs to serialise correctly would require hacks of another order.
This would not really fix#115 but at least get some working if imperfect solution.
Add tests for the new error cases, i.e. when flattening goes wrong
❗ Current head bcbb027 differs from pull request most recent head 775c39d. Consider uploading reports for the commit 775c39d to get more accurate results
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more
…n-rs#455)
* Detect flattened structs in `Deserializer::deserialize_map`
* Add minimal and targeted support for `#[serde(flatten)]`
* Fix the serde flatten canary for MSRV 1.57
* Added extra tests for missing quotation marks in flattened struct field names
* Clean up the serde flatten canary capture
* Document the #[serde(flatten)] hack
* Final small cleanup
---------
Co-authored-by: Clouds Flowing <clouds.flowing@gmail.com>
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes #403, #453, and #454 to add minimal support for
#[serde(flatten)]
in RON. Instead of many workarounds to make flattened structs serialise into nice RON struct syntax and deserialise from them, both of which are really difficult since serde gives us no information to work with and just delegates to map serialisation/deserialisation, this PR just ensures that at least flattened structs can roundtrip through RON.For this, just one hack is necessary. If we detect that a map is deserialised into what looks like a struct (thanks @clouds56 for contributing the detection in #454), we enforce that map key identifiers are actually strings written exactly as
"
, identifier,"
. This seems to be enough to get the tests to work that I initially designed for #403.@torkleyy I'd be in favour of landing this instead of going down the rabbit hole of #403 since that just fixes one of the two parts and getting flattened structs to serialise correctly would require hacks of another order.
This would not really fix #115 but at least get some working if imperfect solution.
CHANGELOG.md