Struct serde_yaml::Mapping
source · [−]pub struct Mapping { /* private fields */ }
Expand description
A YAML mapping in which the keys and values are both serde_yaml::Value
.
Implementations
sourceimpl Mapping
impl Mapping
sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates an empty YAML map with the given initial capacity.
sourcepub fn reserve(&mut self, additional: usize)
pub fn reserve(&mut self, additional: usize)
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
.
sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
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.
sourcepub fn insert(&mut self, k: Value, v: Value) -> Option<Value>
pub fn insert(&mut self, k: Value, v: Value) -> Option<Value>
Inserts a key-value pair into the map. If the key already existed, the old value is returned.
sourcepub fn contains_key<I: Index>(&self, index: I) -> bool
pub fn contains_key<I: Index>(&self, index: I) -> bool
Checks if the map contains the given key.
sourcepub fn get<I: Index>(&self, index: I) -> Option<&Value>
pub fn get<I: Index>(&self, index: I) -> Option<&Value>
Returns the value corresponding to the key in the map.
sourcepub fn get_mut<I: Index>(&mut self, index: I) -> Option<&mut Value>
pub fn get_mut<I: Index>(&mut self, index: I) -> Option<&mut Value>
Returns the mutable reference corresponding to the key in the map.
sourcepub fn entry(&mut self, k: Value) -> Entry<'_>
pub fn entry(&mut self, k: Value) -> Entry<'_>
Gets the given key’s corresponding entry in the map for insertion and/or in-place manipulation.
sourcepub fn remove<I: Index>(&mut self, index: I) -> Option<Value>
pub fn remove<I: Index>(&mut self, index: I) -> Option<Value>
Removes and returns the value corresponding to the key from the map.
sourcepub fn remove_entry<I: Index>(&mut self, index: I) -> Option<(Value, Value)>
pub fn remove_entry<I: Index>(&mut self, index: I) -> Option<(Value, Value)>
Remove and return the key-value pair.
sourcepub fn retain<F>(&mut self, keep: F) where
F: FnMut(&Value, &mut Value) -> bool,
pub fn retain<F>(&mut self, keep: F) where
F: FnMut(&Value, &mut Value) -> bool,
Scan through each key-value pair in the map and keep those where the
closure keep
returns true.
sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the maximum number of key-value pairs the map can hold without reallocating.
sourcepub fn iter(&self) -> Iter<'_>ⓘNotable traits for Iter<'a>impl<'a> Iterator for Iter<'a> type Item = (&'a Value, &'a Value);
pub fn iter(&self) -> Iter<'_>ⓘNotable traits for Iter<'a>impl<'a> Iterator for Iter<'a> type Item = (&'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 Value)
.
sourcepub fn iter_mut(&mut self) -> IterMut<'_>ⓘNotable traits for IterMut<'a>impl<'a> Iterator for IterMut<'a> type Item = (&'a Value, &'a mut Value);
pub fn iter_mut(&mut self) -> IterMut<'_>ⓘNotable traits for IterMut<'a>impl<'a> Iterator for IterMut<'a> type Item = (&'a Value, &'a mut Value);
Returns a double-ended iterator visiting all key-value pairs in order of
insertion. Iterator element type is (&'a Value, &'a mut ValuE)
.
sourcepub fn keys(&self) -> Keys<'_>ⓘNotable traits for Keys<'a>impl<'a> Iterator for Keys<'a> type Item = &'a Value;
pub fn keys(&self) -> Keys<'_>ⓘNotable traits for Keys<'a>impl<'a> Iterator for Keys<'a> type Item = &'a Value;
Return an iterator over the keys of the map.
sourcepub fn into_keys(self) -> IntoKeysⓘNotable traits for IntoKeysimpl Iterator for IntoKeys type Item = Value;
pub fn into_keys(self) -> IntoKeysⓘNotable traits for IntoKeysimpl Iterator for IntoKeys type Item = Value;
Return an owning iterator over the keys of the map.
sourcepub fn values(&self) -> Values<'_>ⓘNotable traits for Values<'a>impl<'a> Iterator for Values<'a> type Item = &'a Value;
pub fn values(&self) -> Values<'_>ⓘNotable traits for Values<'a>impl<'a> Iterator for Values<'a> type Item = &'a Value;
Return an iterator over the values of the map.
sourcepub fn values_mut(&mut self) -> ValuesMut<'_>ⓘNotable traits for ValuesMut<'a>impl<'a> Iterator for ValuesMut<'a> type Item = &'a mut Value;
pub fn values_mut(&mut self) -> ValuesMut<'_>ⓘNotable traits for ValuesMut<'a>impl<'a> Iterator for ValuesMut<'a> type Item = &'a mut Value;
Return an iterator over mutable references to the values of the map.
sourcepub fn into_values(self) -> IntoValuesⓘNotable traits for IntoValuesimpl Iterator for IntoValues type Item = Value;
pub fn into_values(self) -> IntoValuesⓘNotable traits for IntoValuesimpl Iterator for IntoValues type Item = Value;
Return an owning iterator over the values of the map.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Mapping
impl<'de> Deserialize<'de> for Mapping
sourcefn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Extend<(Value, Value)> for Mapping
impl Extend<(Value, Value)> for Mapping
sourcefn extend<I: IntoIterator<Item = (Value, Value)>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = (Value, Value)>>(&mut self, iter: I)
Extends a collection with the contents of an iterator. Read more
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Extends a collection with exactly one element.
sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
sourceimpl FromIterator<(Value, Value)> for Mapping
impl FromIterator<(Value, Value)> for Mapping
sourceimpl<'a> IntoIterator for &'a Mapping
impl<'a> IntoIterator for &'a Mapping
sourceimpl<'a> IntoIterator for &'a mut Mapping
impl<'a> IntoIterator for &'a mut Mapping
sourceimpl IntoIterator for Mapping
impl IntoIterator for Mapping
sourceimpl PartialOrd<Mapping> for Mapping
impl PartialOrd<Mapping> for Mapping
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Eq for Mapping
impl StructuralEq for Mapping
impl StructuralPartialEq for Mapping
Auto Trait Implementations
impl RefUnwindSafe for Mapping
impl Send for Mapping
impl Sync for Mapping
impl Unpin for Mapping
impl UnwindSafe for Mapping
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.