about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-11-17 09:26:57 +0000
committerbors <bors@rust-lang.org>2014-11-17 09:26:57 +0000
commitedfb83c9e28df2a8f326d688f3d5b1f6faa72db8 (patch)
treee9d163e9d31669e9b1233a1997ebc0fd148b76e2 /src/libstd
parent803aacd5aef78f90fdd06ae7653fc20eec224992 (diff)
parentdfb7a811ae0cb8c98ceed93ecc3573555cca03db (diff)
downloadrust-edfb83c9e28df2a8f326d688f3d5b1f6faa72db8.tar.gz
rust-edfb83c9e28df2a8f326d688f3d5b1f6faa72db8.zip
auto merge of #18914 : Gankro/rust/cloned, r=aturon
Part of #18424. r? @aturon 

[breaking-change]
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/collections/hash/map.rs34
1 files changed, 8 insertions, 26 deletions
diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs
index 4d26fa7e26c..779cd425d2a 100644
--- a/src/libstd/collections/hash/map.rs
+++ b/src/libstd/collections/hash/map.rs
@@ -37,7 +37,6 @@ use super::table::{
 };
 
 // FIXME(conventions): update capacity management to match other collections (no auto-shrink)
-// FIXME(conventions): axe find_copy/get_copy in favour of Option.cloned (also implement that)
 
 const INITIAL_LOG2_CAP: uint = 5;
 pub const INITIAL_CAPACITY: uint = 1 << INITIAL_LOG2_CAP; // 2^5
@@ -1220,36 +1219,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()
     }
@@ -1844,6 +1825,7 @@ mod test_map {
     }
 
     #[test]
+    #[allow(deprecated)]
     fn test_find_copy() {
         let mut m = HashMap::new();
         assert!(m.get(&1i).is_none());