Trait indexmap::map::mutable::MutableKeys
source · pub trait MutableKeys: Sealed {
type Key;
type Value;
// Required methods
fn get_full_mut2<Q>(
&mut self,
key: &Q,
) -> Option<(usize, &mut Self::Key, &mut Self::Value)>
where Q: ?Sized + Hash + Equivalent<Self::Key>;
fn get_index_mut2(
&mut self,
index: usize,
) -> Option<(&mut Self::Key, &mut Self::Value)>;
fn iter_mut2(&mut self) -> IterMut2<'_, Self::Key, Self::Value> ⓘ;
fn retain2<F>(&mut self, keep: F)
where F: FnMut(&mut Self::Key, &mut Self::Value) -> bool;
}
Expand description
Opt-in mutable access to IndexMap
keys.
These methods expose &mut K
, mutable references to the key as it is stored
in the map.
You are allowed to modify the keys in the map if the modification
does not change the key’s hash and equality.
If keys are modified erroneously, you can no longer look them up.
This is sound (memory safe) but a logical error hazard (just like
implementing PartialEq
, Eq
, or Hash
incorrectly would be).
use
this trait to enable its methods for IndexMap
.
This trait is sealed and cannot be implemented for types outside this crate.
Required Associated Types§
Required Methods§
sourcefn get_full_mut2<Q>(
&mut self,
key: &Q,
) -> Option<(usize, &mut Self::Key, &mut Self::Value)>
fn get_full_mut2<Q>( &mut self, key: &Q, ) -> Option<(usize, &mut Self::Key, &mut Self::Value)>
Return item index, mutable reference to key and value
Computes in O(1) time (average).
sourcefn get_index_mut2(
&mut self,
index: usize,
) -> Option<(&mut Self::Key, &mut Self::Value)>
fn get_index_mut2( &mut self, index: usize, ) -> Option<(&mut Self::Key, &mut Self::Value)>
Return mutable reference to key and value at an index.
Valid indices are 0 <= index < self.len()
Computes in O(1) time.
sourcefn iter_mut2(&mut self) -> IterMut2<'_, Self::Key, Self::Value> ⓘ
fn iter_mut2(&mut self) -> IterMut2<'_, Self::Key, Self::Value> ⓘ
Return an iterator over the key-value pairs of the map, in their order
Object Safety§
Implementors§
source§impl<K, V, S> MutableKeys for IndexMap<K, V, S>where
S: BuildHasher,
impl<K, V, S> MutableKeys for IndexMap<K, V, S>where
S: BuildHasher,
Opt-in mutable access to IndexMap
keys.
See MutableKeys
for more information.