mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-23 16:21:33 +11:00
Also for remove
This commit is contained in:
parent
11b98eab29
commit
4cace7b01d
|
@ -406,7 +406,21 @@ where
|
||||||
|
|
||||||
/// Removes the given key from the map. Returns the current value if it existed, or [`None`]
|
/// Removes the given key from the map. Returns the current value if it existed, or [`None`]
|
||||||
/// if it did not.
|
/// if it did not.
|
||||||
pub fn remove(&mut self, key: &K) -> Option<V> {
|
///
|
||||||
|
/// # Example
|
||||||
|
/// ```
|
||||||
|
/// use agb_hashmap::HashMap;
|
||||||
|
///
|
||||||
|
/// let mut map = HashMap::new();
|
||||||
|
/// map.insert(1, "a");
|
||||||
|
/// assert_eq!(map.remove(&1), Some("a"));
|
||||||
|
/// assert_eq!(map.remove(&1), None);
|
||||||
|
/// ```
|
||||||
|
pub fn remove<Q>(&mut self, key: &Q) -> Option<V>
|
||||||
|
where
|
||||||
|
K: Borrow<Q>,
|
||||||
|
Q: Hash + Eq + ?Sized,
|
||||||
|
{
|
||||||
let hash = self.hash(key);
|
let hash = self.hash(key);
|
||||||
|
|
||||||
self.nodes
|
self.nodes
|
||||||
|
|
Loading…
Reference in a new issue