pub struct OptionMap<K: PartialEq, V> { /* private fields */ }Expand description
A mapping from keys to optional values.
Wraps a Vec<(K, Option<V>)> and provides convenient access methods.
Implementations§
Source§impl<K: PartialEq, V> OptionMap<K, V>
impl<K: PartialEq, V> OptionMap<K, V>
Sourcepub fn set(&mut self, key: K, value: Option<V>)
pub fn set(&mut self, key: K, value: Option<V>)
Set the value for key (may be None to mark as missing).
Sourcepub fn get(&self, key: &K) -> Option<&V>
pub fn get(&self, key: &K) -> Option<&V>
Get the value for key, or None if not present or explicitly set to None.
Sourcepub fn contains_key(&self, key: &K) -> bool
pub fn contains_key(&self, key: &K) -> bool
Returns true if the key exists (even if mapped to None).
Trait Implementations§
Auto Trait Implementations§
impl<K, V> Freeze for OptionMap<K, V>
impl<K, V> RefUnwindSafe for OptionMap<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for OptionMap<K, V>
impl<K, V> Sync for OptionMap<K, V>
impl<K, V> Unpin for OptionMap<K, V>
impl<K, V> UnsafeUnpin for OptionMap<K, V>
impl<K, V> UnwindSafe for OptionMap<K, V>where
K: UnwindSafe,
V: UnwindSafe,
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