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> PartialEq for Yaml<R>
impl<R: Repr> PartialEq for Yaml<R>
impl<R: Repr> Eq for Yaml<R>
Auto Trait Implementations§
impl<R> RefUnwindSafe for Yaml<R>
impl<R> Send for Yaml<R>
impl<R> Sync for Yaml<R>
impl<R> Unpin for Yaml<R>
impl<R> UnwindSafe for Yaml<R>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more