Skip to content
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

IndexMap doesn't implement Hash #288

Closed
victorteokw opened this issue Nov 9, 2023 · 1 comment
Closed

IndexMap doesn't implement Hash #288

victorteokw opened this issue Nov 9, 2023 · 1 comment

Comments

@victorteokw
Copy link

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

@cuviper
Copy link
Member

cuviper commented Nov 9, 2023

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.

@cuviper cuviper closed this as completed Nov 30, 2023
@cuviper cuviper closed this as not planned Won't fix, can't repro, duplicate, stale Nov 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants