Macro yaml_peg::node [−][src]
macro_rules! node { ([$($token:tt)*] $($opt:tt)*) => { ... }; ({$($token:tt)*} $($opt:tt)*) => { ... }; (null $($opt:tt)*) => { ... }; (*($anchor:expr) $($opt:tt)*) => { ... }; ($yaml:expr $(, $pos:expr $(, $anchor:expr $(, $ty:expr)?)?)?) => { ... }; }
Expand description
Create Node items literally.
Literals and expressions will be transformed to Yaml automatically by calling Into::into.
use yaml_peg::node; let k = "a"; assert_eq!(node!(k), node!("a"));
The members are ordered as node!(yaml, pos, anchor, ty).
Arrays and maps can be created from this macro directly through brackets ([], {}).
use yaml_peg::{node, yaml_array, yaml_map}; assert_eq!(node!([node!(1), node!(2)]), node!(yaml_array![node!(1), node!(2)])); assert_eq!(node!({node!(1) => node!(2)}), node!(yaml_map![node!(1) => node!(2)]));
The Yaml::Null and the Yaml::Null are also supported by the syntax:
use yaml_peg::{node, Yaml}; assert_eq!(node!(Yaml::Null), node!(null)); assert_eq!(node!(Yaml::Anchor("x".into())), node!(*("x")));