pub struct AssocMap<K, V> { /* private fields */ }Expand description
A simple association list map.
Provides O(n) lookup but is useful in contexts where the number of entries is small and allocation overhead should be minimal.
Implementations§
Source§impl<K: PartialEq + Clone, V: Clone> AssocMap<K, V>
impl<K: PartialEq + Clone, V: Clone> AssocMap<K, V>
Sourcepub fn insert(&mut self, key: K, value: V)
pub fn insert(&mut self, key: K, value: V)
Insert a key-value pair, replacing any existing entry for that key.
Sourcepub fn contains_key(&self, key: &K) -> bool
pub fn contains_key(&self, key: &K) -> bool
Check if the map contains a key.
Sourcepub fn iter(&self) -> impl Iterator<Item = &(K, V)>
pub fn iter(&self) -> impl Iterator<Item = &(K, V)>
Iterate over key-value pairs in insertion order.
Trait Implementations§
impl<K, V> StructuralPartialEq for AssocMap<K, V>
Auto Trait Implementations§
impl<K, V> Freeze for AssocMap<K, V>
impl<K, V> RefUnwindSafe for AssocMap<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for AssocMap<K, V>
impl<K, V> Sync for AssocMap<K, V>
impl<K, V> Unpin for AssocMap<K, V>
impl<K, V> UnsafeUnpin for AssocMap<K, V>
impl<K, V> UnwindSafe for AssocMap<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