Skip to main content

MapEntries

Struct MapEntries 

Source
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

Source

pub fn new() -> Self

Construct an empty, unshared map without allocating entry storage.

Source

pub fn with_capacity(capacity: usize) -> Self

Construct an unshared map with room for at least capacity entries.

Source

pub fn with_capacity_and_hasher(capacity: usize, hasher: FxBuildHasher) -> Self

Construct an unshared map with the ordinary ordered map’s hasher.

Source

pub fn len(&self) -> usize

The number of entries.

Source

pub fn is_empty(&self) -> bool

Whether there are no entries.

Source

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.

Source

pub fn is_shared(&self) -> bool

Whether this map currently uses an immutable shared key shape.

Source

pub fn get(&self, key: &str) -> Option<&Value>

Borrow the value at key.

Source

pub fn contains_key(&self, key: &str) -> bool

Whether the key is present.

Source

pub fn get_index_of(&self, key: &str) -> Option<usize>

The insertion-order index of a key.

Source

pub fn get_index(&self, index: usize) -> Option<(&String, &Value)>

Borrow an entry by insertion-order index.

Source

pub fn get_mut(&mut self, key: &str) -> Option<&mut Value>

Mutably borrow one value without changing or copying its key shape.

Source

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.

Source

pub fn iter(&self) -> MapEntriesIter<'_> ⓘ

Borrow entries in insertion order without cloning keys or values.

Source

pub fn keys(&self) -> MapEntriesKeys<'_> ⓘ

Borrow keys in insertion order.

Source

pub fn values(&self) -> MapEntriesValues<'_> ⓘ

Borrow values in insertion order.

Source

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.

Source

pub fn values_mut(&mut self) -> MapEntriesValuesMut<'_> ⓘ

Mutably borrow values in insertion order without copying keys.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for MapEntries

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Extend<(String, Value)> for MapEntries

Source§

fn extend<T: IntoIterator<Item = (String, Value)>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
Source§

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)

🔬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 From<IndexMap<String, Value, FxBuildHasher>> for MapEntries

Source§

fn from(entries: OrderedMap<Value>) -> Self

Converts to this type from the input type.
Source§

impl From<MapEntries> for OrderedMap<Value>

Source§

fn from(entries: MapEntries) -> Self

Converts to this type from the input type.
Source§

impl FromIterator<(String, Value)> for MapEntries

Source§

fn from_iter<T: IntoIterator<Item = (String, Value)>>(iter: T) -> Self

Creates a value from an iterator. Read more
Source§

impl<'a> IntoIterator for &'a MapEntries

Source§

type Item = (&'a String, &'a Value)

The type of the elements being iterated over.
Source§

type IntoIter = MapEntriesIter<'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a> IntoIterator for &'a mut MapEntries

Source§

type Item = (&'a String, &'a mut Value)

The type of the elements being iterated over.
Source§

type IntoIter = MapEntriesIterMut<'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl IntoIterator for MapEntries

Source§

type Item = (String, Value)

The type of the elements being iterated over.
Source§

type IntoIter = MapEntriesIntoIter

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<I> IntoStreamingIterator for I
where I: IntoIterator,

Source§

fn into_streaming_iter(self) -> Convert<Self::IntoIter>

Source§

fn into_streaming_iter_ref<'a, T>(self) -> ConvertRef<'a, Self::IntoIter, T>
where Self: IntoIterator<Item = &'a T>, T: ?Sized,

Turns an IntoIterator of references into a StreamingIterator. Read more
Source§

fn into_streaming_iter_mut<'a, T>(self) -> ConvertMut<'a, Self::IntoIter, T>
where Self: IntoIterator<Item = &'a mut T>, T: ?Sized,

Turns an IntoIterator of mutable references into a StreamingIteratorMut. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.