derive-syn-parse
derive-syn-parse copied to clipboard
Automatic parsing of Vec<SomeSynType> collections
I think the built-in support for bracket/brace/paren delimited things is great. I have been thinking about seeing if I could submit a PR that would make the following "just work":
#[derive(derive_syn_parse::Parse))
struct MyArgs {
#[brace]
_brace: Brace,
#[inside(_brace)]
contents: Vec<Stmt>,
}
In other words, I want to extend derive_syn_parse
so that any Vec
containing a type that implements Parse
is automatically digestible by derive_syn_parse
.
The way this would work under the hood is in the expansion, we would automatically output the following for such fields within the Parse implementation:
let mut #field_name = Vec::new();
while (some condition relating to the subsequent field) {
#field_name.push(input.parse()?);
}
Would you be interested in such a PR and/or do you think something like this would be feasible @sharnoff?