about summary refs log tree commit diff
path: root/library/alloc
diff options
context:
space:
mode:
authorYuki Okushi <jtitor@2k36.org>2022-06-01 23:36:52 +0900
committerGitHub <noreply@github.com>2022-06-01 23:36:52 +0900
commit2c3a8cf0a465705bd010f8952961b9768d1b684e (patch)
tree134d2a7af7e7ee836a7d96cd403ffb559a1217c8 /library/alloc
parenta7bd0d0e07ae1c5c680a32ecf2b5e5556c6935f6 (diff)
parentb02146a370e8e07186d4bd2c264699300ca925df (diff)
Rollup merge of #97611 - azdavis:master, r=Dylan-DPC
Tweak insert docs

For `{Hash, BTree}Map::insert`, I always have to take a few extra seconds to think about the slight weirdness about the fact that if we "did not" insert (which "sounds" false), we return true, and if we "did" insert, (which "sounds" true), we return false.

This tweaks the doc comments for the `insert` methods of those types (as well as what looks like a rustc internal data structure that I found just by searching the codebase for "If the set did") to first use the "Returns whether _something_" pattern used in e.g. `remove`, where we say that `remove` "returns whether the value was present".
Diffstat (limited to 'library/alloc')
-rw-r--r--library/alloc/src/collections/btree/set.rs10
1 files changed, 7 insertions, 3 deletions
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
     ///