Struct serde_yaml::Mapping[][src]

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

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

Implementations

impl Mapping[src]

pub fn new() -> Self[src]

Creates an empty YAML map.

pub fn with_capacity(capacity: usize) -> Self[src]

Creates an empty YAML map with the given initial capacity.

pub fn reserve(&mut self, additional: usize)[src]

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.

pub fn shrink_to_fit(&mut self)[src]

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.

pub fn insert(&mut self, k: Value, v: Value) -> Option<Value>[src]

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

pub fn contains_key(&self, k: &Value) -> bool[src]

Checks if the map contains the given key.

pub fn get(&self, k: &Value) -> Option<&Value>[src]

Returns the value corresponding to the key in the map.

pub fn get_mut(&mut self, k: &Value) -> Option<&mut Value>[src]

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

pub fn remove(&mut self, k: &Value) -> Option<Value>[src]

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

pub fn capacity(&self) -> usize[src]

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

pub fn len(&self) -> usize[src]

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

pub fn is_empty(&self) -> bool[src]

Returns whether the map is currently empty.

pub fn clear(&mut self)[src]

Clears the map of all key-value pairs.

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

Notable traits for Iter<'a>

impl<'a> Iterator for Iter<'a> type Item = (&'a Value, &'a Value);
[src]

Returns a double-ended iterator visiting all key-value pairs in order of insertion. Iterator element type is (&'a Value, &'a 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);
[src]

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

Trait Implementations

impl Clone for Mapping[src]

fn clone(&self) -> Mapping[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Mapping[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl Default for Mapping[src]

fn default() -> Mapping[src]

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

impl<'de> Deserialize<'de> for Mapping[src]

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
    D: Deserializer<'de>, 
[src]

Deserialize this value from the given Serde deserializer. Read more

impl Extend<(Value, Value)> for Mapping[src]

fn extend<I: IntoIterator<Item = (Value, Value)>>(&mut self, iter: I)[src]

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

fn extend_one(&mut self, item: A)[src]

🔬 This is a nightly-only experimental API. (extend_one)

Extends a collection with exactly one element.

fn extend_reserve(&mut self, additional: usize)[src]

🔬 This is a nightly-only experimental API. (extend_one)

Reserves capacity in a collection for the given number of additional elements. Read more

impl From<Mapping> for Value[src]

fn from(f: Mapping) -> Self[src]

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();

impl FromIterator<(Value, Value)> for Mapping[src]

fn from_iter<I: IntoIterator<Item = (Value, Value)>>(iter: I) -> Self[src]

Creates a value from an iterator. Read more

impl Hash for Mapping[src]

fn hash<__H: Hasher>(&self, state: &mut __H)[src]

Feeds this value into the given Hasher. Read more

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given Hasher. Read more

impl<'a> Index<&'a Value> for Mapping[src]

type Output = Value

The returned type after indexing.

fn index(&self, index: &'a Value) -> &Value[src]

Performs the indexing (container[index]) operation. Read more

impl<'a> IndexMut<&'a Value> for Mapping[src]

fn index_mut(&mut self, index: &'a Value) -> &mut Value[src]

Performs the mutable indexing (container[index]) operation. Read more

impl<'a> IntoIterator for &'a Mapping[src]

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

The type of the elements being iterated over.

type IntoIter = Iter<'a>

Which kind of iterator are we turning this into?

fn into_iter(self) -> Self::IntoIter[src]

Creates an iterator from a value. Read more

impl<'a> IntoIterator for &'a mut Mapping[src]

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

The type of the elements being iterated over.

type IntoIter = IterMut<'a>

Which kind of iterator are we turning this into?

fn into_iter(self) -> Self::IntoIter[src]

Creates an iterator from a value. Read more

impl IntoIterator for Mapping[src]

type Item = (Value, Value)

The type of the elements being iterated over.

type IntoIter = IntoIter

Which kind of iterator are we turning this into?

fn into_iter(self) -> Self::IntoIter[src]

Creates an iterator from a value. Read more

impl PartialEq<Mapping> for Mapping[src]

fn eq(&self, other: &Mapping) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &Mapping) -> bool[src]

This method tests for !=.

impl PartialOrd<Mapping> for Mapping[src]

fn partial_cmp(&self, other: &Mapping) -> Option<Ordering>[src]

This method returns an ordering between self and other values if one exists. Read more

#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

impl Serialize for Mapping[src]

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>[src]

Serialize this value into the given Serde serializer. Read more

impl Eq for Mapping[src]

impl StructuralEq for Mapping[src]

impl StructuralPartialEq for Mapping[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]