I was amazed by GitHub - google/argh: Rust derive-based argument parsing optimized for code size which provides macro that we define a struct/enum and all logic are generated so we can run single line of call to parse vector of strings into a structure we want. I was trying to make similar thing to parse a string.
And the problem came to me that I need some macro to extract an enum into data that runtime could inspect.
for example I have:
enum A {
B,
C(String),
D(String, u16),
E(Result<String, String>),
}
I need some data from the structure:
vec![
vec!["B"],
vec!["C", "String"],
vec!["C", "String", "u16"],
vec!["D", "Result", ] // or even some nested structure
]
might be possible to do that with macros like in argh, but I could not figure out how to really make it work by now. Also I know strum
but it does not work with arguments in variant.
Is there any crate that provides similar feature that I could use to extract such data from enum?