pub trait WritableHashMapExt<K: 'static, V: 'static, H: 'static>: Writable<Target = HashMap<K, V, H>> {
// Provided methods
fn clear(&mut self) { ... }
fn retain(&mut self, f: impl FnMut(&K, &mut V) -> bool) { ... }
fn insert(&mut self, k: K, v: V) -> Option<V>
where K: Eq + Hash,
H: BuildHasher { ... }
fn extend(&mut self, iter: impl IntoIterator<Item = (K, V)>)
where K: Eq + Hash,
H: BuildHasher { ... }
fn remove(&mut self, k: &K) -> Option<V>
where K: Eq + Hash,
H: BuildHasher { ... }
fn get_mut(&mut self, k: &K) -> Option<WritableRef<'_, Self, V>>
where K: Eq + Hash,
H: BuildHasher { ... }
}Expand description
An extension trait for Writable<HashMap<K, V, H>> that provides some convenience methods.
Provided Methods§
Sourcefn retain(&mut self, f: impl FnMut(&K, &mut V) -> bool)
fn retain(&mut self, f: impl FnMut(&K, &mut V) -> bool)
Retains only the key-value pairs that match the given predicate.
Sourcefn insert(&mut self, k: K, v: V) -> Option<V>
fn insert(&mut self, k: K, v: V) -> Option<V>
Inserts a key-value pair into the map. If the key was already present, the old value is returned.
Sourcefn extend(&mut self, iter: impl IntoIterator<Item = (K, V)>)
fn extend(&mut self, iter: impl IntoIterator<Item = (K, V)>)
Extends the map with the key-value pairs from the given iterator.
Sourcefn remove(&mut self, k: &K) -> Option<V>
fn remove(&mut self, k: &K) -> Option<V>
Removes a key from the map, returning the value at the key if the key was previously in the map.
Sourcefn get_mut(&mut self, k: &K) -> Option<WritableRef<'_, Self, V>>
fn get_mut(&mut self, k: &K) -> Option<WritableRef<'_, Self, V>>
Get a mutable reference to the value at the given key.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".