Deprecate hashmap's find_copy and get_copy in favour of cloned and clone
This commit is contained in:
parent
04f7b690ba
commit
64efd2650c
@ -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> {
|
||||
/// Deprecated: Use `map.get(k).cloned()`.
|
||||
///
|
||||
/// Return a copy of the value corresponding to the key.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// 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();
|
||||
/// ```
|
||||
#[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()
|
||||
}
|
||||
|
||||
/// Deprecated: Use `map[k].clone()`.
|
||||
///
|
||||
/// Return a copy of the value corresponding to the key.
|
||||
///
|
||||
/// # 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);
|
||||
/// ```
|
||||
#[deprecated = "Use `map[k].clone()`"]
|
||||
pub fn get_copy(&self, k: &K) -> V {
|
||||
self[*k].clone()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user