indexmap-rs/indexmap

.Hash trait

Closed this issue · 2 comments

I'm kind of a noob to Rust, but I commonly use structures similar to this to build "dynamic" types of sorts for when schemas aren't known until runtime (and insertion order must be retained), and then do operations on these objects with HashSets (union, difference, intersect, etc.) That said, I think it would be useful in situations like mine if IndexMap implemented the .Hash trait, similar to how btreemap does.

We currently implement equality independent of order, and Hash has to be consistent when two things are equal, but we don't have an order-independent way to hash. See also #75 and #67.

I'll also note that changing equality comparison is on the list of possible changes for 2.0 (#135), and if we do that it will be feasible to implement Hash as well. Until then, I think we just can't do it, so I'm closing this.

Feel free to reply if you have any more questions about it.