Struct RawOccupiedEntryMut
pub struct RawOccupiedEntryMut<'a, K, V, S> { /* private fields */ }
A raw view into an occupied entry in an IndexMap.
It is part of the RawEntryMut enum.
Implementations
impl<'a, K, V, S> RawOccupiedEntryMut<'a, K, V, S>
fn index(&self) -> usizeReturn the index of the key-value pair
fn key(&self) -> &KGets a reference to the entry's key in the map.
Note that this is not the key that was used to find the entry. There may be an observable difference if the key type has any distinguishing features outside of
HashandEq, like extra fields or the memory address of an allocation.fn key_mut(&mut self) -> &mut KGets a mutable reference to the entry's key in the map.
Note that this is not the key that was used to find the entry. There may be an observable difference if the key type has any distinguishing features outside of
HashandEq, like extra fields or the memory address of an allocation.fn into_key(self) -> &'a mut KConverts into a mutable reference to the entry's key in the map, with a lifetime bound to the map itself.
Note that this is not the key that was used to find the entry. There may be an observable difference if the key type has any distinguishing features outside of
HashandEq, like extra fields or the memory address of an allocation.fn get(&self) -> &VGets a reference to the entry's value in the map.
fn get_mut(&mut self) -> &mut VGets a mutable reference to the entry's value in the map.
If you need a reference which may outlive the destruction of the
RawEntryMutvalue, see [into_mut][Self::into_mut].fn into_mut(self) -> &'a mut VConverts into a mutable reference to the entry's value in the map, with a lifetime bound to the map itself.
fn get_key_value(&self) -> (&K, &V)Gets a reference to the entry's key and value in the map.
fn get_key_value_mut(&mut self) -> (&mut K, &mut V)Gets a reference to the entry's key and value in the map.
fn into_key_value_mut(self) -> (&'a mut K, &'a mut V)Converts into a mutable reference to the entry's key and value in the map, with a lifetime bound to the map itself.
fn insert(&mut self, value: V) -> VSets the value of the entry, and returns the entry's old value.
fn insert_key(&mut self, key: K) -> KSets the key of the entry, and returns the entry's old key.
fn remove(self) -> VRemove the key, value pair stored in the map for this entry, and return the value.
NOTE: This is equivalent to [
.swap_remove()][Self::swap_remove], replacing this entry's position with the last element, and it is deprecated in favor of calling that explicitly. If you need to preserve the relative order of the keys in the map, use [.shift_remove()][Self::shift_remove] instead.fn swap_remove(self) -> VRemove the key, value pair stored in the map for this entry, and return the value.
Like [
Vec::swap_remove][alloc::vec::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!Computes in O(1) time (average).
fn shift_remove(self) -> VRemove the key, value pair stored in the map for this entry, and return the value.
Like [
Vec::remove][alloc::vec::Vec::remove], the pair is removed by shifting all of the elements that follow it, preserving their relative order. This perturbs the index of all of those elements!Computes in O(n) time (average).
fn remove_entry(self) -> (K, V)Remove and return the key, value pair stored in the map for this entry
NOTE: This is equivalent to [
.swap_remove_entry()][Self::swap_remove_entry], replacing this entry's position with the last element, and it is deprecated in favor of calling that explicitly. If you need to preserve the relative order of the keys in the map, use [.shift_remove_entry()][Self::shift_remove_entry] instead.fn swap_remove_entry(self) -> (K, V)Remove and return the key, value pair stored in the map for this entry
Like [
Vec::swap_remove][alloc::vec::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!Computes in O(1) time (average).
fn shift_remove_entry(self) -> (K, V)Remove and return the key, value pair stored in the map for this entry
Like [
Vec::remove][alloc::vec::Vec::remove], the pair is removed by shifting all of the elements that follow it, preserving their relative order. This perturbs the index of all of those elements!Computes in O(n) time (average).
fn move_index(self, to: usize)Moves the position of the entry to a new index by shifting all other entries in-between.
This is equivalent to
IndexMap::move_indexcomingfromthe current [.index()][Self::index].- If
self.index() < to, the other pairs will shift down while the targeted pair moves up. - If
self.index() > to, the other pairs will shift up while the targeted pair moves down.
Panics if
tois out of bounds.Computes in O(n) time (average).
- If
fn swap_indices(self, other: usize)Swaps the position of entry with another.
This is equivalent to
IndexMap::swap_indiceswith the current [.index()][Self::index] as one of the two being swapped.Panics if the
otherindex is out of bounds.Computes in O(1) time (average).
Trait Implementations
impl<K: Debug, V: Debug, S> Debug for RawOccupiedEntryMut<'_, K, V, S>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Auto Trait Implementations
impl<'a, K, V, S> !UnwindSafe for RawOccupiedEntryMut<'a, K, V, S>
impl<'a, K, V, S> Freeze for RawOccupiedEntryMut<'a, K, V, S>
where
OccupiedEntry<'a, K, V>: Freeze,
PhantomData<&'a S>: Freeze,
impl<'a, K, V, S> RefUnwindSafe for RawOccupiedEntryMut<'a, K, V, S>
where
OccupiedEntry<'a, K, V>: RefUnwindSafe,
PhantomData<&'a S>: RefUnwindSafe,
impl<'a, K, V, S> Send for RawOccupiedEntryMut<'a, K, V, S>
where
OccupiedEntry<'a, K, V>: Send,
PhantomData<&'a S>: Send,
impl<'a, K, V, S> Sync for RawOccupiedEntryMut<'a, K, V, S>
where
OccupiedEntry<'a, K, V>: Sync,
PhantomData<&'a S>: Sync,
impl<'a, K, V, S> Unpin for RawOccupiedEntryMut<'a, K, V, S>
where
OccupiedEntry<'a, K, V>: Unpin,
PhantomData<&'a S>: Unpin,
impl<'a, K, V, S> UnsafeUnpin for RawOccupiedEntryMut<'a, K, V, S>
where
OccupiedEntry<'a, K, V>: UnsafeUnpin,
PhantomData<&'a S>: UnsafeUnpin,
Blanket Implementations
impl<T> Any for RawOccupiedEntryMut<'a, K, V, S>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for RawOccupiedEntryMut<'a, K, V, S>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for RawOccupiedEntryMut<'a, K, V, S>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for RawOccupiedEntryMut<'a, K, V, S>
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into<U> for RawOccupiedEntryMut<'a, K, V, S>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for RawOccupiedEntryMut<'a, K, V, S>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for RawOccupiedEntryMut<'a, K, V, S>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>