rustc_data_structures::fx

Type Alias IndexEntry

Source
pub type IndexEntry<'a, K, V> = Entry<'a, K, V>;

Aliased Type§

enum IndexEntry<'a, K, V> {
    Occupied(OccupiedEntry<'a, K, V>),
    Vacant(VacantEntry<'a, K, V>),
}

Variants§

§

Occupied(OccupiedEntry<'a, K, V>)

Existing slot with equivalent key.

§

Vacant(VacantEntry<'a, K, V>)

Vacant slot (no equivalent key in the map).

Layout§

Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.

Implementations

Source§

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

Source

pub fn index(&self) -> usize

Return the index where the key-value pair exists or will be inserted.

Source

pub fn or_insert(self, default: V) -> &'a mut V

Inserts 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).

Source

pub fn or_insert_with<F>(self, call: F) -> &'a mut V
where F: FnOnce() -> V,

Inserts the result of the call function 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).

Source

pub fn or_insert_with_key<F>(self, call: F) -> &'a mut V
where F: FnOnce(&K) -> V,

Inserts the result of the call function 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).

Source

pub fn key(&self) -> &K

Gets 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.

Source

pub fn and_modify<F>(self, f: F) -> Entry<'a, K, V>
where F: FnOnce(&mut V),

Modifies the entry if it is occupied.

Source

pub 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

Source§

impl<K, V> Debug for Entry<'_, K, V>
where K: Debug, V: Debug,

Source§

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

Formats the value using the given formatter. Read more
Source§

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

Opt-in mutable access to Entry keys.

See MutableEntryKey for more information.

Source§

type Key = K

Source§

fn key_mut(&mut self) -> &mut K

Gets a mutable reference to the entry’s key, either within the map if occupied, or else the new key that was used to find the entry.