-
Notifications
You must be signed in to change notification settings - Fork 291
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
Rework the Entry API #535
Rework the Entry API #535
Conversation
☔ The latest upstream changes (presumably #534) made this pull request unmergeable. Please resolve the merge conflicts. |
The main change in this PR is that `OccupiedEntry` no longer holds the key used in the initial `entry` call. As a result, `OccupiedEntryRef` is no longer required since `OccupiedEntry` can be used in `EntryRef` directly. The following methods have been removed: ```rust // hash_map impl OccupiedEntry { fn replace_entry(self, value: V) -> (K, V); fn replace_key(self) -> K; } impl EntryRef { fn and_replace_entry_with<F>(self, f: F) -> Self; } impl VacantEntryRef { fn into_key(self) -> K; } // hash_set impl Entry { fn replace(self) -> T; } ``` The following methods have been added: ```rust impl VacantENtry { fn insert_entry(self, value: V) -> OccupiedEntry<'a, K, V, S, A>; } ``` The following methods have their signatures changed: ```rust impl EntryRef { // Previously returned OccupiedEntryRef fn insert(self, value: V) -> OccupiedEntry<'a, K, V, S, A>; } impl VacantEntryRef { // Previously returned &Q fn key(&self) -> &'b Q; // Previously returned OccupiedEntryRef fn insert(self, value: V) -> OccupiedEntry<'a, K, V, S, A>; } ```
This mirrors the changes done in the main hashbrown API.
@bors r+ |
☀️ Test successful - checks-actions |
How would I keep the key after this change if the key already existed in the map? |
Have you tried using the |
Ah, interesting, didn't know about this one thanks. Is there anything I can read up on why it was done this way? The two APIs seem very similar to me. |
It's a separate API for cases where you want to move the key into the map or make a copy of an existing key without moving it. |
Currently working on updating EDIT: I see, the FCP did decide to close, so, I'll remove it. |
The main change in this PR is that
OccupiedEntry
no longer holds thekey used in the initial
entry
call. As a result,OccupiedEntryRef
isno longer required since
OccupiedEntry
can be used inEntryRef
directly.
The following methods have been removed:
The following methods have been added:
The following methods have their signatures changed: