I ran into issues trying to handle more complex cases (a descriptor for a single-part expression and/or the ability to match designators inside string literals would make it easier/possible to match arbitrary element attributes - currently, it complains that expr
designators can't be followed by >
)
macro_rules! xml {
[<vec>$(<item>$value:ident</item>)*</vec>] => {
vec![$(stringify!($value)),*];
};
}
fn main() {
let items = xml![
<vec>
<item>foo</item>
<item>bar</item>
<item>baz</item>
</vec>
];
println!("{:?}", items);
}