Enum yaml_peg::Yaml

source ·
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§

source§

impl<R: Repr> Clone for Yaml<R>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<R: Repr> Debug for Yaml<R>

source§

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

Formats the value using the given formatter. Read more
source§

impl<R: Repr> From<&String> for Yaml<R>

source§

fn from(s: &String) -> Self

Converts to this type from the input type.
source§

impl<R: Repr> From<&str> for Yaml<R>

source§

fn from(s: &str) -> Self

Converts to this type from the input type.
source§

impl<R: Repr> From<()> for Yaml<R>

source§

fn from(_: ()) -> Self

Converts to this type from the input type.
source§

impl<R: Repr> From<LinkedHashMap<Node<R>, Node<R>>> for Yaml<R>

source§

fn from(m: Map<R>) -> Self

Converts to this type from the input type.
source§

impl<R: Repr> From<String> for Yaml<R>

source§

fn from(s: String) -> Self

Converts to this type from the input type.
source§

impl<R: Repr> From<Vec<Node<R>>> for Yaml<R>

source§

fn from(a: Seq<R>) -> Self

Converts to this type from the input type.
source§

impl<R: Repr> From<bool> for Yaml<R>

source§

fn from(b: bool) -> Self

Converts to this type from the input type.
source§

impl<R: Repr> From<char> for Yaml<R>

source§

fn from(s: char) -> Self

Converts to this type from the input type.
source§

impl<R: Repr> From<f32> for Yaml<R>

source§

fn from(s: f32) -> Self

Converts to this type from the input type.
source§

impl<R: Repr> From<f64> for Yaml<R>

source§

fn from(s: f64) -> Self

Converts to this type from the input type.
source§

impl<R: Repr> From<i128> for Yaml<R>

source§

fn from(s: i128) -> Self

Converts to this type from the input type.
source§

impl<R: Repr> From<i16> for Yaml<R>

source§

fn from(s: i16) -> Self

Converts to this type from the input type.
source§

impl<R: Repr> From<i32> for Yaml<R>

source§

fn from(s: i32) -> Self

Converts to this type from the input type.
source§

impl<R: Repr> From<i64> for Yaml<R>

source§

fn from(s: i64) -> Self

Converts to this type from the input type.
source§

impl<R: Repr> From<i8> for Yaml<R>

source§

fn from(s: i8) -> Self

Converts to this type from the input type.
source§

impl<R: Repr> From<isize> for Yaml<R>

source§

fn from(s: isize) -> Self

Converts to this type from the input type.
source§

impl<R: Repr> From<u128> for Yaml<R>

source§

fn from(s: u128) -> Self

Converts to this type from the input type.
source§

impl<R: Repr> From<u16> for Yaml<R>

source§

fn from(s: u16) -> Self

Converts to this type from the input type.
source§

impl<R: Repr> From<u32> for Yaml<R>

source§

fn from(s: u32) -> Self

Converts to this type from the input type.
source§

impl<R: Repr> From<u64> for Yaml<R>

source§

fn from(s: u64) -> Self

Converts to this type from the input type.
source§

impl<R: Repr> From<u8> for Yaml<R>

source§

fn from(s: u8) -> Self

Converts to this type from the input type.
source§

impl<R: Repr> From<usize> for Yaml<R>

source§

fn from(s: usize) -> Self

Converts to this type from the input type.
source§

impl<R: Repr> FromIterator<(Node<R>, Node<R>)> for Yaml<R>

source§

fn from_iter<T: IntoIterator<Item = (Node<R>, Node<R>)>>(iter: T) -> Self

Creates a value from an iterator. Read more
source§

impl<R: Repr> FromIterator<Node<R>> for Yaml<R>

source§

fn from_iter<T: IntoIterator<Item = Node<R>>>(iter: T) -> Self

Creates a value from an iterator. Read more
source§

impl<R: Repr> Hash for Yaml<R>

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

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

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

impl<R: Repr> PartialEq for Yaml<R>

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<R: Repr> Eq for Yaml<R>

Auto Trait Implementations§

§

impl<R> RefUnwindSafe for Yaml<R>
where R: RefUnwindSafe, <R as Repr>::Rc: RefUnwindSafe,

§

impl<R> Send for Yaml<R>
where R: Send, <R as Repr>::Rc: Send,

§

impl<R> Sync for Yaml<R>
where R: Sync, <R as Repr>::Rc: Sync,

§

impl<R> Unpin for Yaml<R>
where R: Unpin, <R as Repr>::Rc: Unpin,

§

impl<R> UnwindSafe for Yaml<R>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CallHasher for T
where T: Hash + ?Sized,

§

default fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64
where H: Hash + ?Sized, B: BuildHasher,

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

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

Performs the conversion.