pub struct VacantEntry<'a, K, V> {
map: RefMut<'a, K, V>,
hash: HashValue,
key: K,
}
Fields§
§map: RefMut<'a, K, V>
§hash: HashValue
§key: K
Implementations§
Source§impl<'a, K, V> VacantEntry<'a, K, V>
impl<'a, K, V> VacantEntry<'a, K, V>
pub(crate) fn key_mut(&mut self) -> &mut K
Sourcepub fn insert(self, value: V) -> &'a mut V
pub fn insert(self, value: V) -> &'a mut V
Inserts the entry’s key and the given value into the map, and returns a mutable reference to the value.
Computes in O(1) time (amortized average).
Sourcepub fn insert_entry(self, value: V) -> OccupiedEntry<'a, K, V>
pub fn insert_entry(self, value: V) -> OccupiedEntry<'a, K, V>
Inserts the entry’s key and the given value into the map, and returns an OccupiedEntry
.
Computes in O(1) time (amortized average).
Sourcepub fn insert_sorted(self, value: V) -> (usize, &'a mut V)where
K: Ord,
pub fn insert_sorted(self, value: V) -> (usize, &'a mut V)where
K: Ord,
Inserts the entry’s key and the given value into the map at its ordered position among sorted keys, and returns the new index and a mutable reference to the value.
If the existing keys are not already sorted, then the insertion
index is unspecified (like slice::binary_search
), but the key-value
pair is inserted at that position regardless.
Computes in O(n) time (average).
Sourcepub fn insert_sorted_by<F>(self, value: V, cmp: F) -> (usize, &'a mut V)
pub fn insert_sorted_by<F>(self, value: V, cmp: F) -> (usize, &'a mut V)
Inserts the entry’s key and the given value into the map at its ordered
position among keys sorted by cmp
, and returns the new index and a
mutable reference to the value.
If the existing keys are not already sorted, then the insertion
index is unspecified (like slice::binary_search
), but the key-value
pair is inserted at that position regardless.
Computes in O(n) time (average).
Sourcepub fn insert_sorted_by_key<B, F>(
self,
value: V,
sort_key: F,
) -> (usize, &'a mut V)
pub fn insert_sorted_by_key<B, F>( self, value: V, sort_key: F, ) -> (usize, &'a mut V)
Inserts the entry’s key and the given value into the map at its ordered position using a sort-key extraction function, and returns the new index and a mutable reference to the value.
If the existing keys are not already sorted, then the insertion
index is unspecified (like slice::binary_search
), but the key-value
pair is inserted at that position regardless.
Computes in O(n) time (average).
Sourcepub fn shift_insert(self, index: usize, value: V) -> &'a mut V
pub fn shift_insert(self, index: usize, value: V) -> &'a mut V
Inserts the entry’s key and the given value into the map at the given index, shifting others to the right, and returns a mutable reference to the value.
Panics if index
is out of bounds.
Computes in O(n) time (average).
Sourcepub fn replace_index(self, index: usize) -> (K, OccupiedEntry<'a, K, V>)
pub fn replace_index(self, index: usize) -> (K, OccupiedEntry<'a, K, V>)
Replaces the key at the given index with this entry’s key, returning the
old key and an OccupiedEntry
for that index.
Panics if index
is out of bounds.
Computes in O(1) time (average).
Trait Implementations§
Source§impl<K: Debug, V> Debug for VacantEntry<'_, K, V>
impl<K: Debug, V> Debug for VacantEntry<'_, K, V>
Source§impl<K, V> MutableEntryKey for VacantEntry<'_, K, V>
Opt-in mutable access to VacantEntry
keys.
impl<K, V> MutableEntryKey for VacantEntry<'_, K, V>
Opt-in mutable access to VacantEntry
keys.
See MutableEntryKey
for more information.