Skip to content

Commit

Permalink
Revert "Make HashSet::insert return OccupiedEntry"
Browse files Browse the repository at this point in the history
This reverts commit 9beb0d2.
  • Loading branch information
Amanieu committed Apr 28, 2024
1 parent 97c2140 commit 3de77e8
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 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::Vacant(entry) => entry.insert_entry(),
}
}

Expand Down Expand Up @@ -2442,7 +2442,16 @@ 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) -> OccupiedEntry<'a, T, S, A>
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>
where
T: Hash,
S: BuildHasher,
Expand Down

0 comments on commit 3de77e8

Please sign in to comment.