pub struct Map<K, V>(/* private fields */);Expand description
The map used to store the properties of a JsonObject.
The backing implementation and hasher are selected by the preserve_order
and fast_hash cargo features, but this type exposes the same API
regardless of which are enabled. It’s meant to be a drop-in replacement for
the standard library’s HashMap.
Implementations§
Source§impl<K, V> Map<K, V>
impl<K, V> Map<K, V>
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates an empty map with at least the specified capacity.
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Gets the number of entries the map can hold without reallocating.
Sourcepub fn iter_mut(&mut self) -> IterMut<'_, K, V> ⓘ
pub fn iter_mut(&mut self) -> IterMut<'_, K, V> ⓘ
Iterates over the entries with mutable references to the values.
Sourcepub fn values_mut(&mut self) -> ValuesMut<'_, K, V> ⓘ
pub fn values_mut(&mut self) -> ValuesMut<'_, K, V> ⓘ
Iterates over mutable references to the values.
Sourcepub fn into_values(self) -> IntoValues<K, V> ⓘ
pub fn into_values(self) -> IntoValues<K, V> ⓘ
Consumes the map, iterating over its values.
Source§impl<K: Hash + Eq, V> Map<K, V>
impl<K: Hash + Eq, V> Map<K, V>
Sourcepub fn insert(&mut self, key: K, value: V) -> Option<V>
pub fn insert(&mut self, key: K, value: V) -> Option<V>
Inserts an entry, returning the previous value for the key if it existed.
Sourcepub fn entry(&mut self, key: K) -> Entry<'_, K, V>
pub fn entry(&mut self, key: K) -> Entry<'_, K, V>
Gets the entry for the given key for in-place manipulation.
Source§impl<K: Hash + Eq, V> Map<K, V>
impl<K: Hash + Eq, V> Map<K, V>
Sourcepub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>
pub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>
Gets a mutable reference to the value for the given key.
Sourcepub fn get_key_value<Q>(&self, key: &Q) -> Option<(&K, &V)>
pub fn get_key_value<Q>(&self, key: &Q) -> Option<(&K, &V)>
Gets the key and value for the given key.
Sourcepub fn contains_key<Q>(&self, key: &Q) -> bool
pub fn contains_key<Q>(&self, key: &Q) -> bool
Gets if the map contains the given key.
Sourcepub fn remove<Q>(&mut self, key: &Q) -> Option<V>
pub fn remove<Q>(&mut self, key: &Q) -> Option<V>
Removes and returns the value for the given key, preserving the order of the remaining entries.
Sourcepub fn remove_entry<Q>(&mut self, key: &Q) -> Option<(K, V)>
pub fn remove_entry<Q>(&mut self, key: &Q) -> Option<(K, V)>
Removes and returns the entry for the given key, preserving the order of the remaining entries.
Trait Implementations§
impl<K: Hash + Eq, V: Eq> Eq for Map<K, V>
Source§impl<K: Hash + Eq, V> Extend<(K, V)> for Map<K, V>
impl<K: Hash + Eq, V> Extend<(K, V)> for Map<K, V>
Source§fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl<K: Hash + Eq, Q: Hash + Equivalent<K> + ?Sized, V> Index<&Q> for Map<K, V>
Available on crate feature preserve_order only.
impl<K: Hash + Eq, Q: Hash + Equivalent<K> + ?Sized, V> Index<&Q> for Map<K, V>
preserve_order only.Source§impl<K, V> IntoIterator for Map<K, V>
impl<K, V> IntoIterator for Map<K, V>
Source§impl<'a, K, V> IntoIterator for &'a Map<K, V>
impl<'a, K, V> IntoIterator for &'a Map<K, V>
Source§impl<'a, K, V> IntoIterator for &'a mut Map<K, V>
impl<'a, K, V> IntoIterator for &'a mut Map<K, V>
Auto Trait Implementations§
impl<K, V> Freeze for Map<K, V>
impl<K, V> RefUnwindSafe for Map<K, V>where
K: RefUnwindSafe,
V: 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> UnsafeUnpin for Map<K, V>
impl<K, V> UnwindSafe for Map<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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.