pub enum Yaml<R: Repr> {
    Null,
    Bool(bool),
    Int(String),
    Float(String),
    Str(String),
    Seq(Seq<R>),
    Map(Map<R>),
    Alias(String),
}
Expand description

YAML data types, but it is recommended to use Node for shorten code.

This type can convert from primitive types by From and Into traits.

use yaml_peg::YamlRc;

assert_eq!(YamlRc::Int("20".to_string()), YamlRc::from(20));
assert_eq!(YamlRc::Float("0.001".to_string()), 1e-3.into());

Also, the iterators can turned to sequence and map.

use std::iter::FromIterator;
use yaml_peg::{node, YamlRc};

let v = vec![node!(1), node!(2), node!(3)];
assert_eq!(YamlRc::Seq(v.clone()), YamlRc::from_iter(v));
let m = vec![(node!(1), node!(2)), (node!(3), node!(4))];
assert_eq!(
    YamlRc::Map(m.clone().into_iter().collect()),
    YamlRc::from_iter(m)
);

The digit NaN (not-a-number) will be equal in the comparison.

Variants

Null

Null

Bool(bool)

Boolean

Int(String)

Integer

Float(String)

Float

Str(String)

String

Seq(Seq<R>)

Sequence

Map(Map<R>)

Map

Alias(String)

Alias (anchor insertion)

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

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Creates a value from an iterator. Read more

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

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

This method tests for !=.

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

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

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

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.