macro_rules! node {
(@[$v:expr; $n:expr]) => { ... };
(@[$($v:expr),* $(,)?]) => { ... };
(@{$($k:expr => $v:expr),* $(,)?}) => { ... };
(@*$anchor:expr) => { ... };
(@$yaml:expr) => { ... };
(arc $($tt:tt)+) => { ... };
(rc $($tt:tt)+) => { ... };
($($tt:tt)+) => { ... };
}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, Node};
let v = vec![Node::from(1), Node::from(2)];
assert_eq!(node!([1, 2]), v.into_iter().collect());
let m = vec![(Node::from(1), Node::from(2))];
assert_eq!(node!({1 => 2}), m.into_iter().collect());The YamlBase::Anchor is also supported by the syntax:
use yaml_peg::{node, YamlBase};
assert_eq!(node!(YamlBase::Anchor("x".to_string())), node!(*"x"));This macro is use Node by default,
to specify them, a “rc” or “arc” prefix token can choose the presentation.
use yaml_peg::{node, ArcNode};
assert_eq!(node!(arc()), ArcNode::from(()));