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