Skip to content

Commit

Permalink
Tweak insert docs
Browse files Browse the repository at this point in the history
  • Loading branch information
azdavis committed Jun 1, 2022
1 parent 02916c4 commit b02146a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
5 changes: 3 additions & 2 deletions compiler/rustc_data_structures/src/sso/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 7 additions & 3 deletions library/alloc/src/collections/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down
5 changes: 3 additions & 2 deletions library/std/src/collections/hash/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down

0 comments on commit b02146a

Please sign in to comment.