Trait miri::AllocMap

source ·
pub trait AllocMap<K, V>where
    K: Hash + Eq,{
    // Required methods
    fn contains_key<Q>(&mut self, k: &Q) -> bool
       where Q: Hash + Eq + ?Sized,
             K: Borrow<Q>;
    fn insert(&mut self, k: K, v: V) -> Option<V>;
    fn remove<Q>(&mut self, k: &Q) -> Option<V>
       where Q: Hash + Eq + ?Sized,
             K: Borrow<Q>;
    fn filter_map_collect<T>(
        &self,
        f: impl FnMut(&K, &V) -> Option<T>
    ) -> Vec<T, Global>;
    fn get_or<E>(
        &self,
        k: K,
        vacant: impl FnOnce() -> Result<V, E>
    ) -> Result<&V, E>;
    fn get_mut_or<E>(
        &mut self,
        k: K,
        vacant: impl FnOnce() -> Result<V, E>
    ) -> Result<&mut V, E>;

    // Provided methods
    fn get(&self, k: K) -> Option<&V> { ... }
    fn get_mut(&mut self, k: K) -> Option<&mut V> { ... }
}
Expand description

The functionality needed by memory to manage its allocations

Required Methods§

source

fn contains_key<Q>(&mut self, k: &Q) -> boolwhere Q: Hash + Eq + ?Sized, K: Borrow<Q>,

Tests if the map contains the given key. Deliberately takes &mut because that is sufficient, and some implementations can be more efficient then (using RefCell::get_mut).

source

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

Inserts a new entry into the map.

source

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

Removes an entry from the map.

source

fn filter_map_collect<T>( &self, f: impl FnMut(&K, &V) -> Option<T> ) -> Vec<T, Global>

Returns data based on the keys and values in the map.

source

fn get_or<E>( &self, k: K, vacant: impl FnOnce() -> Result<V, E> ) -> Result<&V, E>

Returns a reference to entry k. If no such entry exists, call vacant and either forward its error, or add its result to the map and return a reference to that.

source

fn get_mut_or<E>( &mut self, k: K, vacant: impl FnOnce() -> Result<V, E> ) -> Result<&mut V, E>

Returns a mutable reference to entry k. If no such entry exists, call vacant and either forward its error, or add its result to the map and return a reference to that.

Provided Methods§

source

fn get(&self, k: K) -> Option<&V>

Read-only lookup.

source

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

Mutable lookup.

Implementors§

source§

impl<K: Hash + Eq, V> AllocMap<K, V> for MonoHashMap<K, V>