diff options
| -rw-r--r-- | compiler/rustc_data_structures/src/sso/set.rs | 5 | ||||
| -rw-r--r-- | library/alloc/src/collections/btree/set.rs | 10 | ||||
| -rw-r--r-- | library/std/src/collections/hash/set.rs | 5 |
3 files changed, 13 insertions, 7 deletions
diff --git a/compiler/rustc_data_structures/src/sso/set.rs b/compiler/rustc_data_structures/src/sso/set.rs index f71522d3714..4fda3adb7b8 100644 --- a/compiler/rustc_data_structures/src/sso/set.rs +++ b/compiler/rustc_data_structures/src/sso/set.rs @@ -126,9 +126,10 @@ impl<T: Eq + Hash> SsoHashSet<T> { /// Adds a value to the set. /// - /// If the set did not have this value present, `true` is returned. + /// Returns whether the value was newly inserted. That is: /// - /// If the set did have this value present, `false` is returned. + /// - If the set did not previously contain this value, `true` is returned. + /// - If the set already contained this value, `false` is returned. #[inline] pub fn insert(&mut self, elem: T) -> bool { self.map.insert(elem, ()).is_none() diff --git a/library/alloc/src/collections/btree/set.rs b/library/alloc/src/collections/btree/set.rs index 20ef834eaee..caa629cf4e6 100644 --- a/library/alloc/src/collections/btree/set.rs +++ b/library/alloc/src/collections/btree/set.rs @@ -770,10 +770,14 @@ impl<T> BTreeSet<T> { /// Adds a value to the set. /// - /// If the set did not have an equal element present, `true` is returned. + /// Returns whether the value was newly inserted. That is: /// - /// If the set did have an equal element present, `false` is returned, and - /// the entry is not updated. See the [module-level documentation] for more. + /// - If the set did not previously contain an equal value, `true` is + /// returned. + /// - If the set already contained an equal value, `false` is returned, and + /// the entry is not updated. + /// + /// See the [module-level documentation] for more. /// /// [module-level documentation]: index.html#insert-and-complex-keys /// diff --git a/library/std/src/collections/hash/set.rs b/library/std/src/collections/hash/set.rs index da0572047ec..19428fe9a23 100644 --- a/library/std/src/collections/hash/set.rs +++ b/library/std/src/collections/hash/set.rs @@ -858,9 +858,10 @@ where /// Adds a value to the set. /// - /// If the set did not have this value present, `true` is returned. + /// Returns whether the value was newly inserted. That is: /// - /// If the set did have this value present, `false` is returned. + /// - If the set did not previously contain this value, `true` is returned. + /// - If the set already contained this value, `false` is returned. /// /// # Examples /// |
