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
Hey, I'd like to replace BTreeMap by IndexMap to preserve the order of deserialized elements in RON. However, IndexMap lacks PartialEq, Eq, PartialOrd and Ord.
Is that intentional or just not implemented yet?
The text was updated successfully, but these errors were encountered:
IndexMap does implement equality in the same fashion as HashMap -- maps are considered equal if they contain equal keys and values. This is independent of order, which is natural for HashMap but perhaps surprising for IndexMap.
PartialOrd and Ordmust agree with PartialEq and Eq in what they call Ordering::Equal, which means this comparison must also be independent of the IndexMap's order. It must also be antisymmetric and transitive, as well as being total for Ord. BTreeMap can easily implement a consistent comparison since the keys are sorted, but we have no such luxury here.
If you do know your keys are sorted, or if you just want to compare by each maps' current order regardless, you can iterate them and use Iterator::cmp and friends.
Hey, I'd like to replace
BTreeMap
byIndexMap
to preserve the order of deserialized elements in RON. However,IndexMap
lacksPartialEq
,Eq
,PartialOrd
andOrd
.Is that intentional or just not implemented yet?
The text was updated successfully, but these errors were encountered: