pub enum Entry<'map, Key, Value, State = RandomState> {
    Occupied(OccupiedEntry<'map, Key, Value>),
    Vacant(VacantEntry<'map, Key, Value, State>),
}
Expand description

A view into a single entry in the multimap, which may either be vacant or occupied.

Variants

Occupied(OccupiedEntry<'map, Key, Value>)

An occupied entry associated with one or more values.

Vacant(VacantEntry<'map, Key, Value, State>)

A vacant entry with no associated values.

Implementations

Calls the given function with a mutable reference to the first value of this entry, by insertion order, if it is vacant, otherwise this function is a no-op.

Examples
use ordered_multimap::ListOrderedMultimap;

let mut map = ListOrderedMultimap::new();

map.entry("key")
    .and_modify(|value| *value += 1)
    .or_insert(42);
assert_eq!(map.get(&"key"), Some(&42));

map.entry("key")
    .and_modify(|value| *value += 1)
    .or_insert(42);
assert_eq!(map.get(&"key"), Some(&43));

If the entry is vacant, the given value will be inserted into it and a mutable reference to that value will be returned. Otherwise, a mutable reference to the first value, by insertion order, will be returned.

Examples
use ordered_multimap::ListOrderedMultimap;

let mut map = ListOrderedMultimap::new();
map.insert("key", "value1");

let value = map.entry("key").or_insert("value2");
assert_eq!(value, &"value1");

let value = map.entry("key2").or_insert("value2");
assert_eq!(value, &"value2");
source

pub fn or_insert_entry(self, value: Value) -> OccupiedEntry<'map, Key, Value>

If the entry is vacant, the given value will be inserted into it and the new occupied entry will be returned. Otherwise, the existing occupied entry will be returned.

Examples
use ordered_multimap::ListOrderedMultimap;

let mut map = ListOrderedMultimap::new();
map.insert("key", "value1");

let entry = map.entry("key").or_insert_entry("value2");
assert_eq!(entry.into_mut(), &"value1");

let entry = map.entry("key2").or_insert_entry("value2");
assert_eq!(entry.into_mut(), &"value2");

If the entry is vacant, the value returned from the given function will be inserted into it and a mutable reference to that value will be returned. Otherwise, a mutable reference to the first value, by insertion order, will be returned.

Examples
use ordered_multimap::ListOrderedMultimap;

let mut map = ListOrderedMultimap::new();
map.insert("key", "value1");

let value = map.entry("key").or_insert_with(|| "value2");
assert_eq!(value, &"value1");

let value = map.entry("key2").or_insert_with(|| "value2");
assert_eq!(value, &"value2");
source

pub fn or_insert_with_entry<Function>(
    self,
    function: Function
) -> OccupiedEntry<'map, Key, Value> where
    Function: FnOnce() -> Value, 

If the entry is vacant, the value returned from the given function will be inserted into it and the new occupied entry will be returned. Otherwise, the existing occupied entry will be returned.

Examples
use ordered_multimap::ListOrderedMultimap;

let mut map = ListOrderedMultimap::new();
map.insert("key", "value1");

let entry = map.entry("key").or_insert_with_entry(|| "value2");
assert_eq!(entry.into_mut(), &"value1");

let entry = map.entry("key2").or_insert_with_entry(|| "value2");
assert_eq!(entry.into_mut(), &"value2");

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.