[][src]Macro rdxl::xtype

xtype!() { /* proc-macro */ }

The xtype! macro defines an xml element and subelements

xtype! removes some of the redundancy of defining types having many attribute fields and many heterogenous children elements. A typical type definition that is a good fit for this macro would be coincidentally most XML elements.

In xtype!, a definition might look like this:

xtype!(<!MyList my_string:String my_int:u64>
  <!MyItem my_bool:bool/>
  <!MyOtherItem my_char:char/>
  <?MyPredefinedType/>
</MyList>);

In sugar-free Rust this would become like this:

struct MyPredefinedType {}
struct MyItem { my_bool: bool }
struct MyOtherItem { my_char: char }
enum MyListChildren {
   MyItem(MyItem),
   MyOtherItem(MyOtherItem),
   MyPredefinedType(MyPredefinedType)
}
struct MyList {
   my_string: String,
   my_int: u64,
   children: Vec<MyListChildren>
}