/* * The simplest example */ extern crate macrohelper; use macrohelper::{MacroInput,HashTag}; fn main() { //the example string let dut = r" #[get] pub struct Thing { a: i64 } "; //attempt to parse let help = MacroInput::from_str(dut).expect("simple_struct.rs failed to parse"); //check the attr assert!( help.attr.len() == 1); assert!( help.attr[0].is_word()); assert_eq!( help.attr[0].get_name().unwrap(), "get"); //check the id assert_eq!( help.id, "Thing"); //check the body assert!( help.body.is_struct() ); let body = help.body.get_struct().unwrap(); assert!( body.is_norm()); let fields = body.get_fields().unwrap(); assert_eq!( fields.len(), 1 ); assert_eq!( fields[0].get_name().unwrap(), "a"); }