/* * A simple example for multiple args */ extern crate macrohelper; use macrohelper::{MacroInput,FromLiteral}; fn main() { //the example string let dut = r#" #[Many(Things,Can="Happen",In(Here))] pub struct Tm { pub hours: i32, pub minutes: i32, pub seconds: i32 } "#; //attempt to parse let help = MacroInput::from_str(dut).expect("complex_struct_header.rs failed to parse"); //check the attr assert_eq!( help.attr.len(), 1); assert!( help.attr[0].is_list()); assert_eq!( help.attr[0].get_name().unwrap(), "Many"); assert_eq!( help.attr[0].get_arg_list().unwrap().len(), 3); //check the id assert_eq!( &help.id, "Tm"); //check the body let body = help.body.get_struct().unwrap(); let fields = body.get_fields().unwrap(); assert_eq!(fields.len(), 3); }