pub struct SmallMap<V> { /* private fields */ }Expand description
A map from text keys to V. See the module docs.
Implementations§
Source§impl<V> SmallMap<V>
impl<V> SmallMap<V>
Sourcepub fn get_key_value(&self, key: &str) -> Option<(&str, &V)>
pub fn get_key_value(&self, key: &str) -> Option<(&str, &V)>
The stored key and the value for key.
Sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
True when key has a value.
Sourcepub fn insert<K: AsRef<str> + Into<Box<str>>>(
&mut self,
key: K,
value: V,
) -> Option<V>
pub fn insert<K: AsRef<str> + Into<Box<str>>>( &mut self, key: K, value: V, ) -> Option<V>
Sets the value for key and returns the one it replaces.
Sourcepub fn retain(&mut self, keep: impl FnMut(&str, &mut V) -> bool)
pub fn retain(&mut self, keep: impl FnMut(&str, &mut V) -> bool)
Keeps only the entries for which keep returns true.
Sourcepub fn get_or_insert_with<K: AsRef<str> + Into<Box<str>>>(
&mut self,
key: K,
make: impl FnOnce() -> V,
) -> &mut V
pub fn get_or_insert_with<K: AsRef<str> + Into<Box<str>>>( &mut self, key: K, make: impl FnOnce() -> V, ) -> &mut V
The value for key, inserting make() first when there is none (what entry(key).or_insert_with(make)
does on a BTreeMap). The key is only converted when it is inserted.
Sourcepub fn values_mut(&mut self) -> ValuesMut<'_, V> ⓘ
pub fn values_mut(&mut self) -> ValuesMut<'_, V> ⓘ
The values, mutable, in key order.
Trait Implementations§
Source§impl<'de, V: Deserialize<'de>> Deserialize<'de> for SmallMap<V>
impl<'de, V: Deserialize<'de>> Deserialize<'de> for SmallMap<V>
Source§fn deserialize<D: Deserializer<'de>>(d: D) -> Result<SmallMap<V>, D::Error>
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<SmallMap<V>, D::Error>
From an object; for a repeated key the last value wins, as serde_json does into a BTreeMap.
impl<V: Eq> Eq for SmallMap<V>
Source§impl<K: Into<Box<str>>, V> Extend<(K, V)> for SmallMap<V>
impl<K: Into<Box<str>>, V> Extend<(K, V)> for SmallMap<V>
Source§fn extend<I: IntoIterator<Item = (K, V)>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = (K, V)>>(&mut self, iter: I)
A new value replaces an old one for the same key; of repeated new keys the last wins. A slice merges the new entries in one pass; a tree inserts them one by one.
Source§fn extend_one(&mut self, item: T)
fn extend_one(&mut self, item: T)
🔬This is a nightly-only experimental API. (
extend_one)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
Source§impl<'a, V> IntoIterator for &'a SmallMap<V>
impl<'a, V> IntoIterator for &'a SmallMap<V>
Source§impl<'a, V> IntoIterator for &'a mut SmallMap<V>
impl<'a, V> IntoIterator for &'a mut SmallMap<V>
Source§impl<V> IntoIterator for SmallMap<V>
impl<V> IntoIterator for SmallMap<V>
Source§impl<V: Ord> Ord for SmallMap<V>
impl<V: Ord> Ord for SmallMap<V>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl<V: PartialOrd> PartialOrd for SmallMap<V>
impl<V: PartialOrd> PartialOrd for SmallMap<V>
Source§fn partial_cmp(&self, other: &SmallMap<V>) -> Option<Ordering>
fn partial_cmp(&self, other: &SmallMap<V>) -> Option<Ordering>
Entry by entry, as a BTreeMap compares.
Auto Trait Implementations§
impl<V> Forget for SmallMap<V>
impl<V> Freeze for SmallMap<V>where
Repr<V>: Freeze,
impl<V> Move for SmallMap<V>
impl<V> RefUnwindSafe for SmallMap<V>where
Repr<V>: RefUnwindSafe,
impl<V> Send for SmallMap<V>where
Repr<V>: Send,
impl<V> Sync for SmallMap<V>where
Repr<V>: Sync,
impl<V> Unpin for SmallMap<V>where
Repr<V>: Unpin,
impl<V> UnsafeUnpin for SmallMap<V>where
Repr<V>: UnsafeUnpin,
impl<V> UnwindSafe for SmallMap<V>where
Repr<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