# Struct ordered_multimap::list_ordered_multimap::OccupiedEntry

source · [−]

    pub struct OccupiedEntry<'map, Key, Value> { /* private fields */ }

Expand description

A view into an occupied entry in the multimap.

## Implementations

source

### impl<'map, Key, Value> OccupiedEntry<'map, Key, Value>

source

#### pub fn append(&mut self, value: Value)

##### Examples

    use ordered_multimap::ListOrderedMultimap;
    use ordered_multimap::list_ordered_multimap::Entry;

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

    let mut entry = match map.entry("key") {
        Entry::Occupied(entry) => entry,
        _ => panic!("expected occupied entry")
    };

    entry.append("value2");

    let mut iter = map.get_all(&"key");
    assert_eq!(iter.next(), Some(&"value1"));
    assert_eq!(iter.next(), Some(&"value2"));
    assert_eq!(iter.next(), None);

source

#### pub fn get(&self) -> &Value

##### Examples

    use ordered_multimap::ListOrderedMultimap;
    use ordered_multimap::list_ordered_multimap::Entry;

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

    let mut entry = match map.entry("key") {
        Entry::Occupied(entry) => entry,
        _ => panic!("expected occupied entry")
    };

    assert_eq!(entry.get(), &"value");

source

#### pub fn get_mut(&mut self) -> &mut Value

##### Examples

    use ordered_multimap::ListOrderedMultimap;
    use ordered_multimap::list_ordered_multimap::Entry;

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

    let mut entry = match map.entry("key") {
        Entry::Occupied(entry) => entry,
        _ => panic!("expected occupied entry")
    };

    assert_eq!(entry.get(), &mut "value");

source

#### pub fn insert(&mut self, value: Value) -> Value

##### Examples

    use ordered_multimap::ListOrderedMultimap;
    use ordered_multimap::list_ordered_multimap::Entry;

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

    let mut entry = match map.entry("key") {
        Entry::Occupied(entry) => entry,
        _ => panic!("expected occupied entry")
    };

    entry.insert("value2");

    assert_eq!(map.get(&"key"), Some(&"value2"));

source

#### pub fn insert_all(&mut self, value: Value) -> EntryValuesDrain<'_, Key, Value>ⓘNotable traits for EntryValuesDrain<'_, Key, Value>`impl<Key, Value> Iterator for EntryValuesDrain<'_, Key, Value> type Item = Value;`

##### Examples

    use ordered_multimap::ListOrderedMultimap;
    use ordered_multimap::list_ordered_multimap::Entry;

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

    let mut entry = match map.entry("key") {
        Entry::Occupied(entry) => entry,
        _ => panic!("expected occupied entry")
    };

    entry.append("value2");

    let mut iter = entry.insert_all("value3");
    assert_eq!(iter.next(), Some("value1"));
    assert_eq!(iter.next(), Some("value2"));
    assert_eq!(iter.next(), None);

source

#### pub fn into_mut(self) -> &'map mut Value

##### Examples

    use ordered_multimap::ListOrderedMultimap;
    use ordered_multimap::list_ordered_multimap::Entry;

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

    let mut entry = match map.entry("key") {
        Entry::Occupied(entry) => entry,
        _ => panic!("expected occupied entry")
    };

    assert_eq!(entry.into_mut(), &mut "value");

source

#### pub fn iter(&self) -> EntryValues<'_, Key, Value>ⓘNotable traits for EntryValues<'map, Key, Value>`impl<'map, Key, Value> Iterator for EntryValues<'map, Key, Value> type Item = &'map Value;`

##### Examples

    use ordered_multimap::ListOrderedMultimap;
    use ordered_multimap::list_ordered_multimap::Entry;

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

    let mut entry = match map.entry("key") {
        Entry::Occupied(entry) => entry,
        _ => panic!("expected occupied entry")
    };

    entry.append("value2");

    let mut iter = entry.iter();
    assert_eq!(iter.next(), Some(&"value1"));
    assert_eq!(iter.next(), Some(&"value2"));
    assert_eq!(iter.next(), None);

source

#### pub fn iter_mut(&mut self) -> EntryValuesMut<'_, Key, Value>ⓘNotable traits for EntryValuesMut<'map, Key, Value>`impl<'map, Key, Value> Iterator for EntryValuesMut<'map, Key, Value> type Item = &'map mut Value;`

##### Examples

    use ordered_multimap::ListOrderedMultimap;
    use ordered_multimap::list_ordered_multimap::Entry;

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

    let mut entry = match map.entry("key") {
        Entry::Occupied(entry) => entry,
        _ => panic!("expected occupied entry")
    };

    entry.append("value2");

    let mut iter = entry.iter_mut();
    assert_eq!(iter.next(), Some(&mut "value1"));
    assert_eq!(iter.next(), Some(&mut "value2"));
    assert_eq!(iter.next(), None);

source

#### pub fn key(&self) -> &Key

##### Examples

    use ordered_multimap::ListOrderedMultimap;
    use ordered_multimap::list_ordered_multimap::Entry;

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

    let mut entry = match map.entry("key") {
        Entry::Occupied(entry) => entry,
        _ => panic!("expected occupied entry")
    };

    assert_eq!(entry.key(), &"key");

source

#### pub fn len(&self) -> usize

##### Examples

    use ordered_multimap::ListOrderedMultimap;
    use ordered_multimap::list_ordered_multimap::Entry;

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

    let mut entry = match map.entry("key") {
        Entry::Occupied(entry) => entry,
        _ => panic!("expected occupied entry")
    };

    assert_eq!(entry.len(), 1);

    entry.append("value2");
    assert_eq!(entry.len(), 2);

source

#### pub fn remove(self) -> Value

##### Examples

    use ordered_multimap::ListOrderedMultimap;
    use ordered_multimap::list_ordered_multimap::Entry;

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

    let mut entry = match map.entry("key") {
        Entry::Occupied(entry) => entry,
        _ => panic!("expected occupied entry")
    };

    assert_eq!(entry.remove(), "value");

source

#### pub fn remove_all(self) -> EntryValuesDrain<'map, Key, Value>ⓘNotable traits for EntryValuesDrain<'_, Key, Value>`impl<Key, Value> Iterator for EntryValuesDrain<'_, Key, Value> type Item = Value;`

##### Examples

    use ordered_multimap::ListOrderedMultimap;
    use ordered_multimap::list_ordered_multimap::Entry;

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

    let mut entry = match map.entry("key") {
        Entry::Occupied(entry) => entry,
        _ => panic!("expected occupied entry")
    };

    entry.append("value2");

    let mut iter = entry.remove_all();
    assert_eq!(iter.next(), Some("value1"));
    assert_eq!(iter.next(), Some("value2"));
    assert_eq!(iter.next(), None);

source

#### pub fn remove_entry(self) -> (Key, Value)

##### Examples

    use ordered_multimap::ListOrderedMultimap;
    use ordered_multimap::list_ordered_multimap::Entry;

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

    let mut entry = match map.entry("key") {
        Entry::Occupied(entry) => entry,
        _ => panic!("expected occupied entry")
    };

    assert_eq!(entry.remove_entry(), ("key", "value"));

source

#### pub fn remove_entry_all(self) -> (Key, EntryValuesDrain<'map, Key, Value>)

##### Examples

    use ordered_multimap::ListOrderedMultimap;
    use ordered_multimap::list_ordered_multimap::Entry;

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

    let mut entry = match map.entry("key") {
        Entry::Occupied(entry) => entry,
        _ => panic!("expected occupied entry")
    };

    entry.append("value2");

    let (key, mut iter) = entry.remove_entry_all();
    assert_eq!(key, "key");
    assert_eq!(iter.next(), Some("value1"));
    assert_eq!(iter.next(), Some("value2"));
    assert_eq!(iter.next(), None);

## Trait Implementations

source

### impl<Key, Value> Debug for OccupiedEntry<'_, Key, Value> where
Key: Debug,
Value: Debug,

source

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

Formats the value using the given formatter. Read more

## Auto Trait Implementations

### impl<'map, Key, Value> RefUnwindSafe for OccupiedEntry<'map, Key, Value> where
Key: RefUnwindSafe,
Value: RefUnwindSafe,

### impl<'map, Key, Value> Send for OccupiedEntry<'map, Key, Value> where
Key: Send,
Value: Send,

### impl<'map, Key, Value> Sync for OccupiedEntry<'map, Key, Value> where
Key: Sync,
Value: Sync,

### impl<'map, Key, Value> Unpin for OccupiedEntry<'map, Key, Value>

### impl<'map, Key, Value> !UnwindSafe for OccupiedEntry<'map, Key, Value>

## Blanket Implementations

source

### impl<T> Any for T where
T: 'static + ?Sized,

source

#### fn type_id(&self) -> TypeId

Gets the `TypeId` of `self`. Read more

source

### impl<T> Borrow<T> for T where
T: ?Sized,

const: unstable · source

#### fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more

source

### impl<T> BorrowMut<T> for T where
T: ?Sized,

const: unstable · source

#### fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more

source

### impl<T> From<T> for T

const: unstable · source

#### fn from(t: T) -> T

Returns the argument unchanged.

source

### impl<T, U> Into<U> for T where
U: From<T>,

const: unstable · source

#### fn into(self) -> U

Calls `U::from(self)`.

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

source

### impl<T, U> TryFrom<U> for T where
U: Into<T>,

#### type Error = Infallible

The type returned in the event of a conversion error.

const: unstable · source

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

Performs the conversion.

source

### impl<T, U> TryInto<U> for T where
U: TryFrom<T>,

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

The type returned in the event of a conversion error.

const: unstable · source

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

Performs the conversion.