diff options
| author | Alexis Beingessner <a.beingessner@gmail.com> | 2014-11-07 14:06:18 -0500 |
|---|---|---|
| committer | Alexis Beingessner <a.beingessner@gmail.com> | 2014-11-16 10:40:23 -0500 |
| commit | 64efd2650c22ab508caf191b6f9055463a7a74c4 (patch) | |
| tree | 3f3f8ce915693daf2037cda70d897353847eb728 | |
| parent | 04f7b690ba6b1b6c6cbcf94fb1a9417e6098a887 (diff) | |
| download | rust-64efd2650c22ab508caf191b6f9055463a7a74c4.tar.gz rust-64efd2650c22ab508caf191b6f9055463a7a74c4.zip | |
Deprecate hashmap's find_copy and get_copy in favour of cloned and clone
| -rw-r--r-- | src/libstd/collections/hash/map.rs | 32 |
1 files changed, 7 insertions, 25 deletions
diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 4d26fa7e26c..b4e78d1064b 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -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() } |
