Skip to content

Commit

Permalink
Make HashSet::insert return OccupiedEntry
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
  • Loading branch information
SUPERCILEX committed Feb 16, 2024
1 parent 36ce4b3 commit 9beb0d2
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1003,7 +1003,7 @@ where
/// match singles.entry(ch) {
/// Vacant(single_entry) => {
/// // We found a new character for the first time.
/// single_entry.insert()
/// single_entry.insert();
/// }
/// Occupied(single_entry) => {
/// // We've already seen this once, "move" it to dupes.
Expand Down Expand Up @@ -2211,7 +2211,7 @@ impl<T: fmt::Debug, S, A: Allocator> fmt::Debug for OccupiedEntry<'_, T, S, A> {
///
/// // Nonexistent key (insert)
/// match set.entry("b") {
/// Entry::Vacant(view) => view.insert(),
/// Entry::Vacant(view) => { view.insert(); },
/// Entry::Occupied(_) => unreachable!(),
/// }
/// assert!(set.contains("b") && set.len() == 2);
Expand Down Expand Up @@ -2247,7 +2247,7 @@ impl<'a, T, S, A: Allocator> Entry<'a, T, S, A> {
{
match self {
Entry::Occupied(entry) => entry,
Entry::Vacant(entry) => entry.insert_entry(),
Entry::Vacant(entry) => entry.insert(),
}
}

Expand Down Expand Up @@ -2442,16 +2442,7 @@ impl<'a, T, S, A: Allocator> VacantEntry<'a, T, S, A> {
/// assert!(set.contains("poneyland"));
/// ```
#[cfg_attr(feature = "inline-more", inline)]
pub fn insert(self)
where
T: Hash,
S: BuildHasher,
{
self.inner.insert(());
}

#[cfg_attr(feature = "inline-more", inline)]
fn insert_entry(self) -> OccupiedEntry<'a, T, S, A>
pub fn insert(self) -> OccupiedEntry<'a, T, S, A>
where
T: Hash,
S: BuildHasher,
Expand Down

0 comments on commit 9beb0d2

Please sign in to comment.