Skip to main content

MapMut

Trait MapMut 

Source
pub trait MapMut<K: ?Sized>: MapGet<K>
where Self::Key: Borrow<K>,
{ // Required methods fn get_mut(&mut self, key: &K) -> Option<&mut Self::Value>; fn remove(&mut self, key: &K) -> Option<Self::Value>; }
Expand description

Mutator for a map.

Required Methods§

Source

fn get_mut(&mut self, key: &K) -> Option<&mut Self::Value>

Returns a mutable reference to the value corresponding to the key if exists.

Source

fn remove(&mut self, key: &K) -> Option<Self::Value>

Removes and returns the element at key from the map if exists.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<B: ?Sized + Eq + Hash, K: Borrow<B> + Eq + Hash, V, S: BuildHasher> MapMut<B> for HashMap<K, V, S>

Source§

fn get_mut(&mut self, key: &B) -> Option<&mut Self::Value>

Source§

fn remove(&mut self, key: &B) -> Option<Self::Value>

Source§

impl<B: ?Sized + Ord, K: Borrow<B> + Ord, V> MapMut<B> for BTreeMap<K, V>

Source§

fn get_mut(&mut self, key: &B) -> Option<&mut Self::Value>

Source§

fn remove(&mut self, key: &B) -> Option<Self::Value>

Source§

impl<T> MapMut<usize> for Vec<T>

Source§

fn remove(&mut self, key: &usize) -> Option<Self::Value>

Removes and returns the element at given index, shifting all elements after it to the left.

Source§

fn get_mut(&mut self, key: &usize) -> Option<&mut Self::Value>

Implementors§

Source§

impl<T, I: GenIndex, M> MapMut<I> for GenIndexMap<T, I, M>
where I::Index: TryInto<M::Key>, M: MapMut<<M as Map>::Key, Value = (I, T)>,

Source§

impl<T, I: GenIndex, const N: usize> MapMut<I> for PagedSlotMap<T, I, N>

Source§

impl<T, I: GenIndex> MapMut<I> for SparseSet<T, I>
where I::Index: TryInto<usize>,

Source§

impl<T> MapMut<usize> for VecMap<T>