src/main.rs:
xmacro_rules! create_struct { ( $struct_name: ident { $($field_name: ident : $field_type: ty),* $(,)? } ) => ( pub struct $struct_name { $(pub $field_name: $field_type),* } )}
create_struct!(TestStruct { a: i32, b: String });
fn main() { let t = TestStruct { a: 1, b: "b".to_string(), }; println!("{:#?}", t);}
输出:
xxxxxxxxxxTestStruct { a: 1, b: "b",}