about summary refs log tree commit diff
path: root/library/std/src
diff options
context:
space:
mode:
authorChai T. Rex <ChaiTRex@users.noreply.github.com>2020-12-07 21:36:01 -0500
committerChai T. Rex <ChaiTRex@users.noreply.github.com>2020-12-07 21:36:01 -0500
commitf1b930d57cd9014a4e97c2b0ac366c8fa51f38c7 (patch)
treef628b0d0cd416f990f4f356015ae71b00239468e /library/std/src
parent866ef87d3f1f368687095b263829ef1182b2727a (diff)
downloadrust-f1b930d57cd9014a4e97c2b0ac366c8fa51f38c7.tar.gz
rust-f1b930d57cd9014a4e97c2b0ac366c8fa51f38c7.zip
Improved documentation for HashMap/BTreeMap Entry's .or_insert_with_key method
Diffstat (limited to 'library/std/src')
-rw-r--r--library/std/src/collections/hash/map.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/library/std/src/collections/hash/map.rs b/library/std/src/collections/hash/map.rs
index 323ea5d8244..ae48d7fe7ee 100644
--- a/library/std/src/collections/hash/map.rs
+++ b/library/std/src/collections/hash/map.rs
@@ -2222,9 +2222,12 @@ impl<'a, K, V> Entry<'a, K, V> {
         }
     }
 
-    /// Ensures a value is in the entry by inserting, if empty, the result of the default function,
-    /// which takes the key as its argument, and returns a mutable reference to the value in the
-    /// entry.
+    /// Ensures a value is in the entry by inserting, if empty, the result of the default function.
+    /// This method allows for generating key-derived values for insertion by providing the default
+    /// function a reference to the key that was moved during the `.entry(key)` method call.
+    ///
+    /// The reference to the moved key is provided so that cloning or copying the key is
+    /// unnecessary, unlike with `.or_insert_with(|| ... )`.
     ///
     /// # Examples
     ///