Struct IndexMap
pub struct IndexMap<K, V> { /* private fields */ }
Expand description
Implementations§
§impl<K, V> IndexMap<K, V>
impl<K, V> IndexMap<K, V>
pub fn iter_mut(&mut self) -> IterMut<'_, K, V> ⓘ
pub fn iter_mut(&mut self) -> IterMut<'_, K, V> ⓘ
Returns an iterator that yields the mutable items in the IndexMap
.
pub fn values(&self) -> Values<'_, K, V> ⓘ
pub fn values(&self) -> Values<'_, K, V> ⓘ
Returns an iterator that yields the values in the IndexMap
.
pub fn values_mut(&mut self) -> ValuesMut<'_, K, V> ⓘ
pub fn values_mut(&mut self) -> ValuesMut<'_, K, V> ⓘ
Returns a mutable iterator that yields the values in the IndexMap
.
pub fn get_index(&self, index: usize) -> Option<(&K, &V)>
pub fn get_index(&self, index: usize) -> Option<(&K, &V)>
Returns the key-value entry at the given index
if any.
pub fn get_index_mut(&mut self, index: usize) -> Option<(&K, &mut V)>
pub fn get_index_mut(&mut self, index: usize) -> Option<(&K, &mut V)>
Returns the mutable key-value entry at the given index
if any.
§impl<K, V> IndexMap<K, V>
impl<K, V> IndexMap<K, V>
pub fn reserve(&mut self, additional: usize)
pub fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional
more elements to be inserted in the IndexMap
.
pub fn contains_key<Q>(&self, key: &Q) -> bool
pub fn contains_key<Q>(&self, key: &Q) -> bool
Returns true if key
is contains in the IndexMap
.
pub fn get<Q>(&self, key: &Q) -> Option<&V>
pub fn get<Q>(&self, key: &Q) -> Option<&V>
Returns a reference to the value corresponding to the key
.
pub fn get_key_value<Q>(&self, key: &Q) -> Option<(&K, &V)>
pub fn get_key_value<Q>(&self, key: &Q) -> Option<(&K, &V)>
Return references to the key-value pair stored for key
,
if it is present, else None
.
pub fn get_full<Q>(&self, key: &Q) -> Option<(usize, &K, &V)>
pub fn get_full<Q>(&self, key: &Q) -> Option<(usize, &K, &V)>
Returns the key-value pair corresponding to the supplied key as well as the unique index of the returned key-value pair.
The supplied key may be any borrowed form of the map’s key type, but the ordering on the borrowed form must match the ordering on the key type.
pub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>
pub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>
Returns a mutable reference to the value corresponding to the key.
pub fn insert(&mut self, key: K, value: V) -> Option<V>
pub fn insert(&mut self, key: K, value: V) -> Option<V>
Inserts a key-value pair into the IndexMap
.
If the map did not have this key present, None
is returned.
If the map did have this key present, the value is updated, and the old
value is returned. The key is not updated, though; this matters for
types that can be ==
without being identical.
pub fn swap_remove<Q>(&mut self, key: &Q) -> Option<V>
pub fn swap_remove<Q>(&mut self, key: &Q) -> Option<V>
Remove the key-value pair equivalent to key
and return its value.
Like Vec::swap_remove
, the pair is removed by swapping it with the
last element of the map and popping it off. This perturbs
the position of what used to be the last element!
Return None
if key
is not in map.
pub fn swap_remove_entry<Q>(&mut self, key: &Q) -> Option<(K, V)>
pub fn swap_remove_entry<Q>(&mut self, key: &Q) -> Option<(K, V)>
Remove and return the key-value pair equivalent to key
.
Like Vec::swap_remove
, the pair is removed by swapping it with the
last element of the map and popping it off. This perturbs
the position of what used to be the last element!
Return None
if key
is not in map.
Trait Implementations§
§impl<'a, K, V> Deserialize<'a> for IndexMap<K, V>
impl<'a, K, V> Deserialize<'a> for IndexMap<K, V>
§fn deserialize<D>(
deserializer: D,
) -> Result<IndexMap<K, V>, <D as Deserializer<'a>>::Error>where
D: Deserializer<'a>,
fn deserialize<D>(
deserializer: D,
) -> Result<IndexMap<K, V>, <D as Deserializer<'a>>::Error>where
D: Deserializer<'a>,
§impl<K, V> Extend<(K, V)> for IndexMap<K, V>
impl<K, V> Extend<(K, V)> for IndexMap<K, V>
§fn extend<Iter>(&mut self, iter: Iter)where
Iter: IntoIterator<Item = (K, V)>,
fn extend<Iter>(&mut self, iter: Iter)where
Iter: IntoIterator<Item = (K, V)>,
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)§impl<K, V> FromIterator<(K, V)> for IndexMap<K, V>
impl<K, V> FromIterator<(K, V)> for IndexMap<K, V>
§impl<'a, K, V> IntoIterator for &'a IndexMap<K, V>
impl<'a, K, V> IntoIterator for &'a IndexMap<K, V>
§impl<'a, K, V> IntoIterator for &'a mut IndexMap<K, V>
impl<'a, K, V> IntoIterator for &'a mut IndexMap<K, V>
§impl<K, V> IntoIterator for IndexMap<K, V>
impl<K, V> IntoIterator for IndexMap<K, V>
§impl<K, V> Serialize for IndexMap<K, V>
impl<K, V> Serialize for IndexMap<K, V>
§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
impl<K, V> Eq for IndexMap<K, V>
Auto Trait Implementations§
impl<K, V> Freeze for IndexMap<K, V>
impl<K, V> RefUnwindSafe for IndexMap<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for IndexMap<K, V>
impl<K, V> Sync for IndexMap<K, V>
impl<K, V> Unpin for IndexMap<K, V>
impl<K, V> UnwindSafe for IndexMap<K, V>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.