Is it possible to write a declarative macro in Rust that takes a tree like structure of blocks and creates a combined assortment of enums? I'm trying to determine if this is only possible with procedural macros, or if I can get away with using TT munchers. Recursion isn't the only challenge, as I would also need to combine the identifiers used to label each block, like Exposure
and Mode
becoming ExposureMode
, which I can't seem to find a means of achieving.
For example, given a statement like:
enum_tree! {
Exposure {
Mode {
FullAuto,
Manual,
ShutterPriority,
IrisPriority,
GainPriority,
},
Iris {
Reset,
Up,
Down,
Direct(u8),
},
},
Focus {
In,
Out,
Stop,
}
}
would yield a result like:
enum ExposureMode {
FullAuto,
Manual,
ShutterPriority,
IrisPriority,
GainPriority,
}
enum ExposureIris {
Reset,
Up,
Down,
Direct(u8),
}
enum Focus {
In,
Out,
Stop,
}