Macro leetcode::tree

source ·
macro_rules! tree {
    () => { ... };
    ($($e:expr),*) => { ... };
    ($($e:expr,)*) => { ... };
}
Expand description

Generate a tree structure from a vec-like syntax.

For example:

#[macro_use] extern crate leetcode;
use std::rc::Rc;
use std::cell::RefCell;
use leetcode::{tree, TreeNode};

let tree_node: Option<Rc<RefCell<TreeNode>>> = tree![4,2,7,1,3,6,9];

will be expanded to an optional value: Option<Rc<RefCell<TreeNode>>> which with the following tree structure:

     4
   /   \
  2     7
 / \   / \
1   3 6   9

And:

#[macro_use] extern crate leetcode;
use std::rc::Rc;
use std::cell::RefCell;
use leetcode::{tree, TreeNode};

let tree_node: Option<Rc<RefCell<TreeNode>>> = tree![4,2,7,null,null,6,9];

will be expanded to an optional value: Option<Rc<RefCell<TreeNode>>> which with the following tree structure:

       4
     /   \
    2     7
   / \   / \
        6   9