pub trait AnyMap<K, V> {
// Required methods
fn len(&self) -> usize;
fn insert(&mut self, key: K, value: V) -> Option<V>;
fn get<Q>(&self, key: &Q) -> Option<&V>
where K: Borrow<Q>,
Q: Hash + Eq + ?Sized;
fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>
where K: Borrow<Q>,
Q: Hash + Eq + ?Sized;
fn remove<Q>(&mut self, key: &Q) -> Option<V>
where K: Borrow<Q>,
Q: Hash + Eq + ?Sized;
fn contains_key<Q>(&self, key: &Q) -> bool
where K: Borrow<Q>,
Q: Hash + Eq + ?Sized;
fn clear(&mut self);
// Provided method
fn is_empty(&self) -> bool { ... }
}Expand description
A trait for abstraction over different map types (Stack, Heap, Small).
Required Methods§
Sourcefn insert(&mut self, key: K, value: V) -> Option<V>
fn insert(&mut self, key: K, value: V) -> Option<V>
Inserts the given key-value pair or element.
Sourcefn get<Q>(&self, key: &Q) -> Option<&V>
fn get<Q>(&self, key: &Q) -> Option<&V>
Returns a reference to the value corresponding to the key.
Sourcefn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>
fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>
Returns a reference to the value corresponding to the key.
Sourcefn contains_key<Q>(&self, key: &Q) -> bool
fn contains_key<Q>(&self, key: &Q) -> bool
Returns true if the collection contains the item or key.
Provided Methods§
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.