using rust to derive debug and display
use std::fmt;
#[derive(Debug)]
pub enum ASTNode {
Leaf{key:String, val:String},
Branch{key:String, children:Vec<ASTNode>}
}
impl fmt::Display for ASTNode {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
_ => write!(f, "{:?}", self)
}
}
}
fn main(){
println!("{}", ASTNode::Branch{key:"h".to_string(), children:vec![ASTNode::Leaf{key:"f".to_string(), val:"42".to_string()}]});
}
//Branch { key: "h", children: [Leaf { key: "f", val: "42" }] }