Also for remove

This commit is contained in:
Gwilym Inzani 2023-04-23 18:45:39 +01:00
parent 11b98eab29
commit 4cace7b01d

View file

@ -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