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
sourceimpl<R: Repr> FromIterator<Node<R>> for Yaml<R>
impl<R: Repr> FromIterator<Node<R>> for Yaml<R>
sourcefn from_iter<T: IntoIterator<Item = Node<R>>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = Node<R>>>(iter: T) -> Self
Creates a value from an iterator. Read more
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> where
R: UnwindSafe + RefUnwindSafe,
<R as Repr>::Rc: UnwindSafe + RefUnwindSafe,
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<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more