Skip to content

Commit

Permalink
Deprecate hashmap's find_copy and get_copy in favour of cloned and clone
Browse files Browse the repository at this point in the history
  • Loading branch information
Gankra committed Nov 16, 2014
1 parent 04f7b69 commit 64efd26
Showing 1 changed file with 7 additions and 25 deletions.
32 changes: 7 additions & 25 deletions src/libstd/collections/hash/map.rs
Expand Up @@ -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()
}
Expand Down

0 comments on commit 64efd26

Please sign in to comment.