Struct VacantEntry

struct VacantEntry<'a, K, V> { ... }

A view into a vacant entry in an [IndexMap][crate::IndexMap]. It is part of the Entry enum.

Implementations

impl<'a, K, V> VacantEntry<'a, K, V>

fn index(self: &Self) -> usize

Return the index where a key-value pair may be inserted.

fn key(self: &Self) -> &K

Gets a reference to the key that was used to find the entry.

fn into_key(self: Self) -> K

Takes ownership of the key, leaving the entry vacant.

fn insert(self: 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).

fn insert_entry(self: 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).

fn insert_sorted(self: 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).

fn shift_insert(self: 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).

impl<'a, K, V> Freeze for VacantEntry<'a, K, V>

impl<'a, K, V> RefUnwindSafe for VacantEntry<'a, K, V>

impl<'a, K, V> Send for VacantEntry<'a, K, V>

impl<'a, K, V> Sync for VacantEntry<'a, K, V>

impl<'a, K, V> Unpin for VacantEntry<'a, K, V>

impl<'a, K, V> UnsafeUnpin for VacantEntry<'a, K, V>

impl<'a, K, V> UnwindSafe for VacantEntry<'a, K, V>

impl<K, V> MutableEntryKey for VacantEntry<'_, K, V>

fn key_mut(self: &mut Self) -> &mut <Self as >::Key

impl<K: fmt::Debug, V> Debug for VacantEntry<'_, K, V>

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

impl<T> Any for VacantEntry<'a, K, V>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for VacantEntry<'a, K, V>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for VacantEntry<'a, K, V>

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> From for VacantEntry<'a, K, V>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into for VacantEntry<'a, K, V>

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for VacantEntry<'a, K, V>

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for VacantEntry<'a, K, V>

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>