]> git.lizzy.rs Git - rust.git/blobdiff - library/std/src/collections/hash/map.rs
Auto merge of #76128 - poliorcetics:doc-use-arc-clone, r=KodrAus
[rust.git] / library / std / src / collections / hash / map.rs
index 77cc5b93dbb5029a16f76db73c7a0c44efb00d08..57cb179a4244a4fd6e46d6783f28227d244d8108 100644 (file)
@@ -2382,7 +2382,7 @@ pub fn replace_entry(self, value: V) -> (K, V) {
     /// use std::rc::Rc;
     ///
     /// let mut map: HashMap<Rc<String>, u32> = HashMap::new();
-    /// let mut known_strings: Vec<Rc<String>> = Vec::new();
+    /// let known_strings: Vec<Rc<String>> = Vec::new();
     ///
     /// // Initialise known strings, run program, etc.
     ///
@@ -2390,7 +2390,7 @@ pub fn replace_entry(self, value: V) -> (K, V) {
     ///
     /// fn reclaim_memory(map: &mut HashMap<Rc<String>, u32>, known_strings: &[Rc<String>] ) {
     ///     for s in known_strings {
-    ///         if let Entry::Occupied(entry) = map.entry(s.clone()) {
+    ///         if let Entry::Occupied(entry) = map.entry(Rc::clone(s)) {
     ///             // Replaces the entry's key with our version of it in `known_strings`.
     ///             entry.replace_key();
     ///         }