WritableHashMapExt

Trait WritableHashMapExt 

Source
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§

Source

fn clear(&mut self)

Clears the map, removing all key-value pairs.

Source

fn retain(&mut self, f: impl FnMut(&K, &mut V) -> bool)

Retains only the key-value pairs that match the given predicate.

Source

fn insert(&mut self, k: K, v: V) -> Option<V>
where K: Eq + Hash, H: BuildHasher,

Inserts a key-value pair into the map. If the key was already present, the old value is returned.

Source

fn extend(&mut self, iter: impl IntoIterator<Item = (K, V)>)
where K: Eq + Hash, H: BuildHasher,

Extends the map with the key-value pairs from the given iterator.

Source

fn remove(&mut self, k: &K) -> Option<V>
where K: Eq + Hash, H: BuildHasher,

Removes a key from the map, returning the value at the key if the key was previously in the map.

Source

fn get_mut(&mut self, k: &K) -> Option<WritableRef<'_, Self, V>>
where K: Eq + Hash, H: BuildHasher,

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", so this trait is not object safe.

Implementors§

Source§

impl<K: 'static, V: 'static, H: 'static, R> WritableHashMapExt<K, V, H> for R
where R: Writable<Target = HashMap<K, V, H>>,