pub struct MapEntries { /* private fields */ }Expand description
Insertion-ordered map entries with independent values and optional shared keys. Duplicate insertion replaces the value at the original key position.
Cloning clones each value exactly once. When keys are shared, cloning retains
their immutable shape instead of cloning the key strings. Use
Self::as_ordered_mut for operations specific to an ordinary ordered map.
Implementations§
Source§impl MapEntries
impl MapEntries
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Construct an unshared map with room for at least capacity entries.
Sourcepub fn with_capacity_and_hasher(capacity: usize, hasher: FxBuildHasher) -> Self
pub fn with_capacity_and_hasher(capacity: usize, hasher: FxBuildHasher) -> Self
Construct an unshared map with the ordinary ordered map’s hasher.
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
The capacity of this map’s value storage. For shared maps this is the value vector’s capacity, not the capacity of the shared key table.
Whether this map currently uses an immutable shared key shape.
Sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
Whether the key is present.
Sourcepub fn get_index_of(&self, key: &str) -> Option<usize>
pub fn get_index_of(&self, key: &str) -> Option<usize>
The insertion-order index of a key.
Sourcepub fn get_index(&self, index: usize) -> Option<(&String, &Value)>
pub fn get_index(&self, index: usize) -> Option<(&String, &Value)>
Borrow an entry by insertion-order index.
Sourcepub fn get_mut(&mut self, key: &str) -> Option<&mut Value>
pub fn get_mut(&mut self, key: &str) -> Option<&mut Value>
Mutably borrow one value without changing or copying its key shape.
Sourcepub fn get_index_mut(&mut self, index: usize) -> Option<(&String, &mut Value)>
pub fn get_index_mut(&mut self, index: usize) -> Option<(&String, &mut Value)>
Borrow a key and mutably borrow its value by insertion-order index.
Sourcepub fn iter(&self) -> MapEntriesIter<'_> ⓘ
pub fn iter(&self) -> MapEntriesIter<'_> ⓘ
Borrow entries in insertion order without cloning keys or values.
Sourcepub fn keys(&self) -> MapEntriesKeys<'_> ⓘ
pub fn keys(&self) -> MapEntriesKeys<'_> ⓘ
Borrow keys in insertion order.
Sourcepub fn values(&self) -> MapEntriesValues<'_> ⓘ
pub fn values(&self) -> MapEntriesValues<'_> ⓘ
Borrow values in insertion order.
Sourcepub fn iter_mut(&mut self) -> MapEntriesIterMut<'_> ⓘ
pub fn iter_mut(&mut self) -> MapEntriesIterMut<'_> ⓘ
Borrow keys and mutably borrow values in insertion order. Keys remain immutable and each mutable value belongs to this map alone.
Sourcepub fn values_mut(&mut self) -> MapEntriesValuesMut<'_> ⓘ
pub fn values_mut(&mut self) -> MapEntriesValuesMut<'_> ⓘ
Mutably borrow values in insertion order without copying keys.
Sourcepub fn insert(&mut self, key: String, value: Value) -> Option<Value>
pub fn insert(&mut self, key: String, value: Value) -> Option<Value>
Insert or replace an entry. Replacing an existing key keeps its original position and returns its previous value without promoting shared keys. Adding a key promotes shared storage before insertion.
Sourcepub fn shift_remove(&mut self, key: &str) -> Option<Value>
pub fn shift_remove(&mut self, key: &str) -> Option<Value>
Remove a key, shifting later entries left while preserving their order. An absent key leaves the representation unchanged.
Sourcepub fn swap_remove(&mut self, key: &str) -> Option<Value>
pub fn swap_remove(&mut self, key: &str) -> Option<Value>
Remove a key, moving the last entry into its position. An absent key leaves the representation unchanged.
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Remove all values in insertion order. Shared storage becomes an empty ordinary map without first allocating or cloning a key table.
Sourcepub fn as_ordered_mut(&mut self) -> &mut OrderedMap<Value>
pub fn as_ordered_mut(&mut self) -> &mut OrderedMap<Value>
Obtain ordinary mutable map storage. Shared keys are cloned and values are moved exactly once; other maps retain their keys and values. Subsequent ordered-map operations follow the ordinary map API.
Sourcepub fn into_ordered(self) -> OrderedMap<Value>
pub fn into_ordered(self) -> OrderedMap<Value>
Consume the entries as an ordinary ordered map. Shared keys are cloned; values are moved, preserving their order and identity.
Trait Implementations§
Source§impl Clone for MapEntries
impl Clone for MapEntries
Source§fn clone(&self) -> MapEntries
fn clone(&self) -> MapEntries
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for MapEntries
impl Default for MapEntries
Source§impl Extend<(String, Value)> for MapEntries
impl Extend<(String, Value)> for MapEntries
Source§fn extend<T: IntoIterator<Item = (String, Value)>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = (String, Value)>>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: T)
fn extend_one(&mut self, item: T)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)