Trait rustc_const_eval::interpret::AllocMap
source · pub trait AllocMap<K: Hash + Eq, V> {
// Required methods
fn contains_key<Q: ?Sized + Hash + Eq>(&mut self, k: &Q) -> bool
where K: Borrow<Q>;
fn insert(&mut self, k: K, v: V) -> Option<V>;
fn remove<Q: ?Sized + Hash + Eq>(&mut self, k: &Q) -> Option<V>
where K: Borrow<Q>;
fn filter_map_collect<T>(
&self,
f: impl FnMut(&K, &V) -> Option<T>
) -> Vec<T>;
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§
sourcefn contains_key<Q: ?Sized + Hash + Eq>(&mut self, k: &Q) -> boolwhere
K: Borrow<Q>,
fn contains_key<Q: ?Sized + Hash + Eq>(&mut self, k: &Q) -> boolwhere 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
).
sourcefn remove<Q: ?Sized + Hash + Eq>(&mut self, k: &Q) -> Option<V>where
K: Borrow<Q>,
fn remove<Q: ?Sized + Hash + Eq>(&mut self, k: &Q) -> Option<V>where K: Borrow<Q>,
Removes an entry from the map.
sourcefn filter_map_collect<T>(&self, f: impl FnMut(&K, &V) -> Option<T>) -> Vec<T>
fn filter_map_collect<T>(&self, f: impl FnMut(&K, &V) -> Option<T>) -> Vec<T>
Returns data based on the keys and values in the map.