pub struct Mapping { /* private fields */ }
Expand description

A YAML mapping in which the keys and values are both serde_yaml::Value.

Implementations

Creates an empty YAML map.

Creates an empty YAML map with the given initial capacity.

Reserves capacity for at least additional more elements to be inserted into the map. The map may reserve more space to avoid frequent allocations.

Panics

Panics if the new allocation size overflows usize.

Shrinks the capacity of the map as much as possible. It will drop down as much as possible while maintaining the internal rules and possibly leaving some space in accordance with the resize policy.

Inserts a key-value pair into the map. If the key already existed, the old value is returned.

Checks if the map contains the given key.

Returns the value corresponding to the key in the map.

Returns the mutable reference corresponding to the key in the map.

Gets the given key’s corresponding entry in the map for insertion and/or in-place manipulation.

Removes and returns the value corresponding to the key from the map.

source

pub fn remove_entry<I: Index>(&mut self, index: I) -> Option<(Value, Value)>

Remove and return the key-value pair.

Scan through each key-value pair in the map and keep those where the closure keep returns true.

Returns the maximum number of key-value pairs the map can hold without reallocating.

Returns the number of key-value pairs in the map.

Returns whether the map is currently empty.

Clears the map of all key-value pairs.

Returns a double-ended iterator visiting all key-value pairs in order of insertion. Iterator element type is (&'a Value, &'a Value).

Returns a double-ended iterator visiting all key-value pairs in order of insertion. Iterator element type is (&'a Value, &'a mut ValuE).

Return an iterator over the keys of the map.

Return an owning iterator over the keys of the map.

Return an iterator over the values of the map.

Return an iterator over mutable references to the values of the map.

Return an owning iterator over the values of the map.

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Deserialize this value from the given Serde deserializer. Read more
Extends a collection with the contents of an iterator. Read more
🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more

Convert map (with string keys) to Value

Examples
use serde_yaml::{Mapping, Value};

let mut m = Mapping::new();
m.insert("Lorem".into(), "ipsum".into());
let x: Value = m.into();
Creates a value from an iterator. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
The returned type after indexing.
Performs the indexing (container[index]) operation. Read more
Performs the mutable indexing (container[index]) operation. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Compare self to key and return true if they are equal.

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.