Macro yaml_peg::node[][src]

macro_rules! node {
    ([$($token : tt) *]) => { ... };
    ({ $($token : tt) * }) => { ... };
    (null) => { ... };
    (* $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;
let k = "a";
assert_eq!(node!(k), node!("a"));

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 YamlBase::Null and the YamlBase::Null are also supported by the syntax:

use yaml_peg::{node, YamlBase};
assert_eq!(node!(YamlBase::Null), node!(null));
assert_eq!(node!(YamlBase::Anchor("x".into())), node!(*"x"));