Enum Entry
pub enum Entry<'a, K, V>
Entry for an existing key-value pair in an [IndexMap][crate::IndexMap]
or a vacant location to insert one.
Variants
-
Occupied(OccupiedEntry<'a, K, V>) Existing slot with equivalent key.
-
Vacant(VacantEntry<'a, K, V>) Vacant slot (no equivalent key in the map).
Implementations
impl<'a, K, V> Entry<'a, K, V>
fn index(&self) -> usizeReturn the index where the key-value pair exists or will be inserted.
fn insert_entry(self, value: V) -> OccupiedEntry<'a, K, V>Sets the value of the entry (after inserting if vacant), and returns an
OccupiedEntry.Computes in O(1) time (amortized average).
fn or_insert(self, default: V) -> &'a mut VInserts the given default value in the entry if it is vacant and returns a mutable reference to it. Otherwise a mutable reference to an already existent value is returned.
Computes in O(1) time (amortized average).
fn or_insert_with<F>(self, call: F) -> &'a mut V where F: FnOnce() -> V,Inserts the result of the
callfunction in the entry if it is vacant and returns a mutable reference to it. Otherwise a mutable reference to an already existent value is returned.Computes in O(1) time (amortized average).
fn or_insert_with_key<F>(self, call: F) -> &'a mut V where F: FnOnce(&K) -> V,Inserts the result of the
callfunction with a reference to the entry's key if it is vacant, and returns a mutable reference to the new value. Otherwise a mutable reference to an already existent value is returned.Computes in O(1) time (amortized average).
fn key(&self) -> &KGets a reference to the entry's key, either within the map if occupied, or else the new key that was used to find the entry.
fn and_modify<F>(self, f: F) -> Self where F: FnOnce(&mut V),Modifies the entry if it is occupied.
fn or_default(self) -> &'a mut V where V: Default,Inserts a default-constructed value in the entry if it is vacant and returns a mutable reference to it. Otherwise a mutable reference to an already existent value is returned.
Computes in O(1) time (amortized average).
Trait Implementations
impl<K, V> MutableEntryKey for Entry<'_, K, V>
type Key = K;fn key_mut(&mut self) -> &mut Self::Key
impl<K: Debug, V: Debug> Debug for Entry<'_, K, V>
fn fmt(&self, f: &mut Formatter<'_>) -> Result