pub struct Map<K, V> { /* private fields */ }Expand description
An ordered, deduplicated collection of key-value pairs.
Implementations§
Source§impl<K: Ord, V> Map<K, V>
impl<K: Ord, V> Map<K, V>
Sourcepub fn from_iter_dedup<I: IntoIterator<Item = (K, V)>>(iter: I) -> Self
pub fn from_iter_dedup<I: IntoIterator<Item = (K, V)>>(iter: I) -> Self
Creates a new Map from an iterator, removing duplicate keys.
Unlike FromIterator and From, this method tolerates duplicate
keys by silently discarding them (keeping the first occurrence).
Source§impl<K, V> Map<K, V>
impl<K, V> Map<K, V>
Sourcepub fn position(&self, key: &K) -> Option<usize>where
K: Ord,
pub fn position(&self, key: &K) -> Option<usize>where
K: Ord,
Returns the position of the provided key, if it exists.
Sourcepub fn value(&self, index: usize) -> Option<&V>
pub fn value(&self, index: usize) -> Option<&V>
Returns the associated value at index, if it exists.
Sourcepub fn get_value(&self, key: &K) -> Option<&V>where
K: Ord,
pub fn get_value(&self, key: &K) -> Option<&V>where
K: Ord,
Returns the associated value for key, if it exists.
Sourcepub fn get_value_mut(&mut self, key: &K) -> Option<&mut V>where
K: Ord,
pub fn get_value_mut(&mut self, key: &K) -> Option<&mut V>where
K: Ord,
Returns a mutable reference to the associated value for key, if it exists.
Sourcepub fn values_mut(&mut self) -> &mut [V]
pub fn values_mut(&mut self) -> &mut [V]
Returns a mutable reference to the associated values
Sourcepub fn iter_pairs(&self) -> impl Iterator<Item = (&K, &V)>
pub fn iter_pairs(&self) -> impl Iterator<Item = (&K, &V)>
Returns a zipped iterator over keys and values.
Methods from Deref<Target = Set<K>>§
Trait Implementations§
Source§impl<K: EncodeSize, V: EncodeSize> EncodeSize for Map<K, V>
impl<K: EncodeSize, V: EncodeSize> EncodeSize for Map<K, V>
Source§fn encode_size(&self) -> usize
fn encode_size(&self) -> usize
Returns the encoded size of this value (in bytes).
Source§impl<'a, K, V> IntoIterator for &'a Map<K, V>
impl<'a, K, V> IntoIterator for &'a Map<K, V>
Source§impl<K, V> IntoIterator for Map<K, V>
impl<K, V> IntoIterator for Map<K, V>
Source§impl<K: Read + Ord, V: Read> Read for Map<K, V>
impl<K: Read + Ord, V: Read> Read for Map<K, V>
impl<K: Eq, V: Eq> Eq for Map<K, V>
impl<K, V> StructuralPartialEq for Map<K, V>
Auto Trait Implementations§
impl<K, V> Freeze for Map<K, V>
impl<K, V> RefUnwindSafe for Map<K, V>where
V: RefUnwindSafe,
K: RefUnwindSafe,
impl<K, V> Send for Map<K, V>
impl<K, V> Sync for Map<K, V>
impl<K, V> Unpin for Map<K, V>
impl<K, V> UnwindSafe for Map<K, V>where
V: UnwindSafe,
K: UnwindSafe,
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)