IndexMap doesn't implement `Hash`
victorteokw opened this issue · comments
Hi,
Thanks for this great package. When I use some type which contains IndexMap as keys to some other map, I get this error message. Could this be implemented or this is by design?
Thanks
It is by design, because its Eq
is based on containing equivalent items regardless of order, like HashMap
, and Hash
has to be consistent with Eq
if they're both implemented. But this comes up often: #67, #75, #155, and a bit of #153.
The indexmap::map::Slice
type does implement order-sensitive Eq
and Hash
, so you could possibly use a wrapper for your keys that forwards to the map .as_slice()
for those operations.