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

Move the hasher to the inner HashMap #22

Closed
wants to merge 2 commits into from

Conversation

cuviper
Copy link
Contributor

@cuviper cuviper commented Jan 7, 2024

This is an alternate to #21 that gives HashMap control of most hashing, by introducing a private NodeKey<K, V> type around the node pointer that only looks at K for equality and hashing. A private NodeQ wrapper also works to enable the generic K: Borrow<Q> relationship while having NodeKey in the middle.

As with #21, LinkedHashMap::reserve and try_reserve are now constrained such that K can be (re)hashed with S, which is needed when hashbrown tries to move them to a new allocation. The new test_reserve demonstrates a case that would have previously failed.

In addition, OccupiedEntry and RawOccupiedEntryMut now carry the S parameter as well, since hashbrown's entry type needs it now that it's not just NullHasher (which has been removed).

@kyren
Copy link
Owner

kyren commented Jan 9, 2024

Closed in favor of #21

@kyren kyren closed this Jan 9, 2024
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

Successfully merging this pull request may close these issues.

2 participants