-
Notifications
You must be signed in to change notification settings - Fork 132
Use indexmap to preserve order (optional) #172
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, this would only preserve the order of Value
types but not regular maps?
#[cfg(not(feature = "indexmap"))] | ||
type MapInner = std::collections::BTreeMap<Value, Value>; | ||
#[cfg(feature = "indexmap")] | ||
type MapInner = indexmap::IndexMap<Value, Value>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happens if we just typedef type Map = indexmap::IndexMap<..>
instead of wrapping it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll end up with a non-additive feature. BTreeMap
and IndexMap
have different properties (traits, methods, etc.).
Also, APIs accepting BTreeMap
would break once indexmap
is enabled.
Exactly. If one wants to preserve the order elsewhere, they should use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not feeling super comfortable reviewing the Value mode, since I don't use it.
You have my stamp though :)
Thanks for the review! |
172: Use indexmap to preserve order (optional) r=torkleyy a=torkleyy Introduces an optional `indexmap` feature which uses `IndexMap` in `Value::Map` to preserve the order of deserialized elements. Fixes #129 Co-authored-by: Thomas Schaller <[email protected]>
Build succeeded |
Introduces an optional
indexmap
feature which usesIndexMap
inValue::Map
to preserve the order of deserialized elements.Fixes #129