[][src]Enum ordered_multimap::list_ordered_multimap::Entry

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

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.

Methods

impl<'map, Key, Value, State> Entry<'map, Key, Value, State> where
    Key: Eq + Hash,
    State: BuildHasher
[src]

pub fn and_modify<Function>(self, function: Function) -> Self where
    Function: FnOnce(&mut Value), 
[src]

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));

pub fn or_insert(self, value: Value) -> &'map mut Value[src]

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");

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

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");

pub fn or_insert_with<Function>(self, function: Function) -> &'map mut Value where
    Function: FnOnce() -> Value, 
[src]

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");

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

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

impl<'map, Key, Value, State> Debug for Entry<'map, Key, Value, State> where
    Key: Debug,
    State: BuildHasher,
    Value: Debug
[src]

Auto Trait Implementations

impl<'map, Key, Value, State> RefUnwindSafe for Entry<'map, Key, Value, State> where
    Key: RefUnwindSafe,
    State: RefUnwindSafe,
    Value: RefUnwindSafe

impl<'map, Key, Value, State> Send for Entry<'map, Key, Value, State> where
    Key: Send,
    State: Sync,
    Value: Send

impl<'map, Key, Value, State> Sync for Entry<'map, Key, Value, State> where
    Key: Sync,
    State: Sync,
    Value: Sync

impl<'map, Key, Value, State> Unpin for Entry<'map, Key, Value, State> where
    Key: Unpin

impl<'map, Key, Value, State = RandomState> !UnwindSafe for Entry<'map, Key, Value, State>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,