pub trait Map<K, V>: Containerwhere
K: Eq,{
// Required methods
fn get<Q>(&self, key: &Q) -> Option<&V>
where K: Borrow<Q>,
Q: Eq + ?Sized;
fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut V>
where K: Borrow<Q>,
Q: Eq + ?Sized;
fn insert(&mut self, k: K, v: V) -> Option<V>;
}
Expand description
Trait for a container indexed by a value that implements Eq
.
Required Methods§
Sourcefn get<Q>(&self, key: &Q) -> Option<&V>
fn get<Q>(&self, key: &Q) -> Option<&V>
Returns a reference to a value from this Map.
Takes a key by reference
and returns a reference to the corresponding data,
or None
if the key doesn’t exist in the map.
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.