Enum yaml_peg::YamlBase[][src]

pub enum YamlBase<R: Repr> {
    Null,
    Bool(bool),
    Int(String),
    Float(String),
    Str(String),
    Array(Array<R>),
    Map(Map<R>),
    Anchor(String),
}
Expand description

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

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

use yaml_peg::Yaml;

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

Also, the iterators can turn into arrays and maps.

use yaml_peg::{Yaml, node};
use yaml_peg::{yaml_array, yaml_map};

use std::iter::FromIterator;
let v = vec![node!(1), node!(2), node!(3)];
assert_eq!(Yaml::from_iter(v), yaml_array![node!(1), node!(2), node!(3)]);
let m = vec![(node!(1), node!(2)), (node!(3), node!(4))];
assert_eq!(Yaml::from_iter(m), yaml_map!{node!(1) => node!(2), node!(3) => node!(4)});

Variants

Null

Null

Bool(bool)

Boolean

Int(String)

Integer

Float(String)

Float

Str(String)

String

Array(Array<R>)

Array

Map(Map<R>)

Map

Anchor(String)

Anchor insertion

Implementations

Check the anchor is valid.

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

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

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

Performs the conversion.

Performs the conversion.

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)

recently added

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.