rust-lang / hashbrown

Rust port of Google's SwissTable hash map
https://rust-lang.github.io/hashbrown
Apache License 2.0
2.38k stars 275 forks source link

Rework the Entry API #535

Closed Amanieu closed 2 weeks ago

Amanieu commented 2 months ago

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:

// 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:

impl VacantEntry {
    fn insert_entry(self, value: V) -> OccupiedEntry<'a, K, V, S, A>;
}

The following methods have their signatures changed:

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>;
}
bors commented 2 weeks ago

:umbrella: The latest upstream changes (presumably #534) made this pull request unmergeable. Please resolve the merge conflicts.

Amanieu commented 2 weeks ago

@bors r+

bors commented 2 weeks ago

:pushpin: Commit 731dfccb5dacabeed20fec441e2cebec50512734 has been approved by Amanieu

It is now in the queue for this repository.

bors commented 2 weeks ago

:hourglass: Testing commit 731dfccb5dacabeed20fec441e2cebec50512734 with merge f1ba3b4547f5a8f0d4b679e4f44298138d89be59...

bors commented 2 weeks ago

:sunny: Test successful - checks-actions Approved by: Amanieu Pushing f1ba3b4547f5a8f0d4b679e4f44298138d89be59 to master...