Trait AsImHashMap

Source
pub trait AsImHashMap<K: Hash + Eq + Clone, V: Clone>: Clone {
    // Required methods
    fn insert(&mut self, k: K, v: V) -> Option<V>;
    fn remove<BK: Hash + Eq + ?Sized>(&mut self, k: &BK) -> Option<V>
       where K: Borrow<BK>;
    fn remove_with_key<BK: Hash + Eq + ?Sized>(
        &mut self,
        k: &BK,
    ) -> Option<(K, V)>
       where K: Borrow<BK>;
    fn retain<F: FnMut(&K, &V) -> bool>(&mut self, f: F);

    // Provided methods
    fn to_inserted(&self, k: K, v: V) -> (Self, Option<V>) { ... }
    fn to_removed<BK: Hash + Eq + ?Sized>(
        &mut self,
        k: &BK,
    ) -> (Self, Option<V>)
       where K: Borrow<BK> { ... }
    fn to_removed_with_key<BK: Hash + Eq + ?Sized>(
        &mut self,
        k: &BK,
    ) -> (Self, Option<(K, V)>)
       where K: Borrow<BK> { ... }
    fn to_retained<F: FnMut(&K, &V) -> bool>(&self, f: F) -> Self { ... }
    fn to_extended<I: IntoIterator<Item = (K, V)>>(&self, iter: I) -> Self
       where Self: Extend<(K, V)> { ... }
    fn iter_clone(&self) -> Self::IntoIter
       where Self: IntoIterator { ... }
}

Required Methods§

Source

fn insert(&mut self, k: K, v: V) -> Option<V>

Source

fn remove<BK: Hash + Eq + ?Sized>(&mut self, k: &BK) -> Option<V>
where K: Borrow<BK>,

Source

fn remove_with_key<BK: Hash + Eq + ?Sized>(&mut self, k: &BK) -> Option<(K, V)>
where K: Borrow<BK>,

Source

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

Provided Methods§

Source

fn to_inserted(&self, k: K, v: V) -> (Self, Option<V>)

Source

fn to_removed<BK: Hash + Eq + ?Sized>(&mut self, k: &BK) -> (Self, Option<V>)
where K: Borrow<BK>,

Source

fn to_removed_with_key<BK: Hash + Eq + ?Sized>( &mut self, k: &BK, ) -> (Self, Option<(K, V)>)
where K: Borrow<BK>,

Source

fn to_retained<F: FnMut(&K, &V) -> bool>(&self, f: F) -> Self

Source

fn to_extended<I: IntoIterator<Item = (K, V)>>(&self, iter: I) -> Self
where Self: Extend<(K, V)>,

Source

fn iter_clone(&self) -> Self::IntoIter
where Self: IntoIterator,

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.

Implementations on Foreign Types§

Source§

impl<K: Hash + Eq + Clone, V: Clone, S: BuildHasher> AsImHashMap<K, V> for HashMap<K, V, S>

Source§

fn insert(&mut self, k: K, v: V) -> Option<V>

Source§

fn remove<BK: Hash + Eq + ?Sized>(&mut self, k: &BK) -> Option<V>
where K: Borrow<BK>,

Source§

fn remove_with_key<BK: Hash + Eq + ?Sized>(&mut self, k: &BK) -> Option<(K, V)>
where K: Borrow<BK>,

Source§

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

Source§

impl<K: Hash + Eq + Clone, V: Clone, S: BuildHasher> AsImHashMap<K, V> for HashMap<K, V, S>

Source§

fn insert(&mut self, k: K, v: V) -> Option<V>

Source§

fn remove<BK: Hash + Eq + ?Sized>(&mut self, k: &BK) -> Option<V>
where K: Borrow<BK>,

Source§

fn remove_with_key<BK: Hash + Eq + ?Sized>(&mut self, k: &BK) -> Option<(K, V)>
where K: Borrow<BK>,

Source§

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

Implementors§