macro_rules! binary_tree { (@ $n:ident { }) => { ... }; (@ $n:ident { right: $value:expr => $children:tt$(,)* }) => { ... }; (@ $n:ident { left: $value:expr => $children:tt$(,)* }) => { ... }; (@ $n:ident { left: $value:expr$(,)* }) => { ... }; (@ $n:ident { right: $value:expr$(,)* }) => { ... }; (@ $n:ident { left: $left_value:expr, right: $right_value:expr => $right_children:tt$(,)* }) => { ... }; (@ $n:ident { left: $left_value:expr, right: $right_value:expr$(,)* }) => { ... }; (@ $n:ident { left: $left_value:expr => $left_children:tt, right: $right_value:expr$(,)* }) => { ... }; (@ $n:ident { left: $left_value:expr => $left_children:tt, right: $right_value:expr => $right_children:tt$(,)* }) => { ... }; ($root:expr) => { ... }; ($root:expr => $children:tt) => { ... }; }
Expand description
Creates a binary tree from expressions.
ยงExamples
#[macro_use] extern crate ego_binary_tree;
let tree = binary_tree!("root");
#[macro_use] extern crate ego_binary_tree;
let tree = binary_tree! {
"root" => {
left: "child a",
right: "child b" => {
right: "grandchild a",
},
}
};