about summary refs log tree commit diff
path: root/compiler/rustc_data_structures/src
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 /compiler/rustc_data_structures/src
parenta7bd0d0e07ae1c5c680a32ecf2b5e5556c6935f6 (diff)
parentb02146a370e8e07186d4bd2c264699300ca925df (diff)
downloadrust-2c3a8cf0a465705bd010f8952961b9768d1b684e.tar.gz
rust-2c3a8cf0a465705bd010f8952961b9768d1b684e.zip
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 'compiler/rustc_data_structures/src')
-rw-r--r--compiler/rustc_data_structures/src/sso/set.rs5
1 files changed, 3 insertions, 2 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()