Skip to content

Commit

Permalink
Rework the Entry API
Browse files Browse the repository at this point in the history
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>;
}
```
  • Loading branch information
Amanieu committed Jun 22, 2024
1 parent 4c824c5 commit 9a394f6
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 862 deletions.
Loading

0 comments on commit 9a394f6

Please sign in to comment.