]> git.lizzy.rs Git - rust.git/commitdiff
Deprecate hashmap's find_copy and get_copy in favour of cloned and clone
authorAlexis Beingessner <a.beingessner@gmail.com>
Fri, 7 Nov 2014 19:06:18 +0000 (14:06 -0500)
committerAlexis Beingessner <a.beingessner@gmail.com>
Sun, 16 Nov 2014 15:40:23 +0000 (10:40 -0500)
src/libstd/collections/hash/map.rs

index 4d26fa7e26c090d5111b3c0d2ab3c0f43f60df15..b4e78d1064b08aae4a9e851ed4adeed5a43307b7 100644 (file)
@@ -1220,36 +1220,18 @@ fn search_entry_hashed<'a, K: Eq, V>(table: &'a mut RawTable<K,V>, hash: SafeHas
 }
 
 impl<K: Eq + Hash<S>, V: Clone, S, H: Hasher<S>> HashMap<K, V, H> {
-    /// Return a copy of the value corresponding to the key.
-    ///
-    /// # Example
+    /// Deprecated: Use `map.get(k).cloned()`.
     ///
-    /// ```
-    /// use std::collections::HashMap;
-    ///
-    /// let mut map: HashMap<uint, String> = HashMap::new();
-    /// map.insert(1u, "foo".to_string());
-    /// let s: String = map.find_copy(&1).unwrap();
-    /// ```
+    /// Return a copy of the value corresponding to the key.
+    #[deprecated = "Use `map.get(k).cloned()`"]
     pub fn find_copy(&self, k: &K) -> Option<V> {
-        self.get(k).map(|v| (*v).clone())
+        self.get(k).cloned()
     }
 
-    /// Return a copy of the value corresponding to the key.
+    /// Deprecated: Use `map[k].clone()`.
     ///
-    /// # Panics
-    ///
-    /// Panics if the key is not present.
-    ///
-    /// # Example
-    ///
-    /// ```
-    /// use std::collections::HashMap;
-    ///
-    /// let mut map: HashMap<uint, String> = HashMap::new();
-    /// map.insert(1u, "foo".to_string());
-    /// let s: String = map.get_copy(&1);
-    /// ```
+    /// Return a copy of the value corresponding to the key.
+    #[deprecated = "Use `map[k].clone()`"]
     pub fn get_copy(&self, k: &K) -> V {
         self[*k].clone()
     }