Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 274c7bb

Browse files
committedFeb 18, 2024
Auto merge of #495 - SUPERCILEX:insert, r=Amanieu
Make HashSet::insert return OccupiedEntry See rust-lang/rust#120077 (comment)
2 parents 36ce4b3 + 9beb0d2 commit 274c7bb

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed
 

‎src/set.rs

+4-13
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ where
10031003
/// match singles.entry(ch) {
10041004
/// Vacant(single_entry) => {
10051005
/// // We found a new character for the first time.
1006-
/// single_entry.insert()
1006+
/// single_entry.insert();
10071007
/// }
10081008
/// Occupied(single_entry) => {
10091009
/// // We've already seen this once, "move" it to dupes.
@@ -2211,7 +2211,7 @@ impl<T: fmt::Debug, S, A: Allocator> fmt::Debug for OccupiedEntry<'_, T, S, A> {
22112211
///
22122212
/// // Nonexistent key (insert)
22132213
/// match set.entry("b") {
2214-
/// Entry::Vacant(view) => view.insert(),
2214+
/// Entry::Vacant(view) => { view.insert(); },
22152215
/// Entry::Occupied(_) => unreachable!(),
22162216
/// }
22172217
/// assert!(set.contains("b") && set.len() == 2);
@@ -2247,7 +2247,7 @@ impl<'a, T, S, A: Allocator> Entry<'a, T, S, A> {
22472247
{
22482248
match self {
22492249
Entry::Occupied(entry) => entry,
2250-
Entry::Vacant(entry) => entry.insert_entry(),
2250+
Entry::Vacant(entry) => entry.insert(),
22512251
}
22522252
}
22532253

@@ -2442,16 +2442,7 @@ impl<'a, T, S, A: Allocator> VacantEntry<'a, T, S, A> {
24422442
/// assert!(set.contains("poneyland"));
24432443
/// ```
24442444
#[cfg_attr(feature = "inline-more", inline)]
2445-
pub fn insert(self)
2446-
where
2447-
T: Hash,
2448-
S: BuildHasher,
2449-
{
2450-
self.inner.insert(());
2451-
}
2452-
2453-
#[cfg_attr(feature = "inline-more", inline)]
2454-
fn insert_entry(self) -> OccupiedEntry<'a, T, S, A>
2445+
pub fn insert(self) -> OccupiedEntry<'a, T, S, A>
24552446
where
24562447
T: Hash,
24572448
S: BuildHasher,

0 commit comments

Comments
 (0)
Failed to load comments.