pub struct IndexMap<K, V> { /* private fields */ }
Expand description
Implementations§
Source§impl<K, V> IndexMap<K, V>
impl<K, V> IndexMap<K, V>
Sourcepub fn iter(&self) -> Iter<'_, K, V> ⓘ
pub fn iter(&self) -> Iter<'_, K, V> ⓘ
Returns an iterator that yields the items in the IndexMap
.
Sourcepub 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
.
Sourcepub fn keys(&self) -> Keys<'_, K, V> ⓘ
pub fn keys(&self) -> Keys<'_, K, V> ⓘ
Returns an iterator that yields the keys in the IndexMap
.
Sourcepub fn values(&self) -> Values<'_, K, V> ⓘ
pub fn values(&self) -> Values<'_, K, V> ⓘ
Returns an iterator that yields the values in the IndexMap
.
Sourcepub 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
.
Source§impl<K, V> IndexMap<K, V>
impl<K, V> IndexMap<K, V>
Sourcepub 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
.
Sourcepub 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
.
Sourcepub 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
.
Sourcepub 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
.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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§
Source§impl<K, V> Extend<(K, V)> for IndexMap<K, V>
impl<K, V> Extend<(K, V)> for IndexMap<K, V>
Source§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
)Source§impl<K, V> FromIterator<(K, V)> for IndexMap<K, V>
impl<K, V> FromIterator<(K, V)> for IndexMap<K, V>
Source§impl<'a, K, V> IntoIterator for &'a IndexMap<K, V>
impl<'a, K, V> IntoIterator for &'a IndexMap<K, V>
Source§impl<'a, K, V> IntoIterator for &'a mut IndexMap<K, V>
impl<'a, K, V> IntoIterator for &'a mut IndexMap<K, V>
Source§impl<K, V> IntoIterator for IndexMap<K, V>
impl<K, V> IntoIterator for IndexMap<K, V>
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>where
K: UnwindSafe,
V: UnwindSafe,
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
)Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more