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>
impl<'map, Key, Value> OccupiedEntry<'map, Key, Value>
sourcepub fn append(&mut self, value: Value)
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);
sourcepub fn get(&self) -> &Value
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");
sourcepub fn get_mut(&mut self) -> &mut Value
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");
sourcepub fn insert(&mut self, value: Value) -> Value
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"));
sourcepub fn insert_all(&mut self, value: Value) -> EntryValuesDrain<'_, Key, Value> ⓘ
pub fn insert_all(&mut self, value: Value) -> EntryValuesDrain<'_, 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 mut iter = entry.insert_all("value3");
assert_eq!(iter.next(), Some("value1"));
assert_eq!(iter.next(), Some("value2"));
assert_eq!(iter.next(), None);
sourcepub fn into_mut(self) -> &'map mut Value
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");
sourcepub fn iter(&self) -> EntryValues<'_, Key, Value> ⓘ
pub fn iter(&self) -> EntryValues<'_, 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 mut iter = entry.iter();
assert_eq!(iter.next(), Some(&"value1"));
assert_eq!(iter.next(), Some(&"value2"));
assert_eq!(iter.next(), None);
sourcepub fn iter_mut(&mut self) -> EntryValuesMut<'_, Key, Value> ⓘ
pub fn iter_mut(&mut self) -> EntryValuesMut<'_, 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 mut iter = entry.iter_mut();
assert_eq!(iter.next(), Some(&mut "value1"));
assert_eq!(iter.next(), Some(&mut "value2"));
assert_eq!(iter.next(), None);
sourcepub fn key(&self) -> &Key
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");
sourcepub fn len(&self) -> usize
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);
sourcepub fn remove(self) -> Value
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");
sourcepub fn remove_all(self) -> EntryValuesDrain<'map, Key, Value> ⓘ
pub fn remove_all(self) -> 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 mut iter = entry.remove_all();
assert_eq!(iter.next(), Some("value1"));
assert_eq!(iter.next(), Some("value2"));
assert_eq!(iter.next(), None);
sourcepub fn remove_entry(self) -> (Key, Value)
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"));
sourcepub fn remove_entry_all(self) -> (Key, EntryValuesDrain<'map, Key, Value>)
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§
Auto Trait Implementations§
impl<'map, Key, Value> Freeze for OccupiedEntry<'map, Key, Value>
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>
impl<'map, Key, Value> Sync for OccupiedEntry<'map, Key, Value>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more