Committing to a conversion
In order to aid the creation of correct ASTs, it's sometimes useful to know when things go wrong when you don't expect. I propose adding a #[pest_ast(commit)] or similar, after which conversions in the sequence which would otherwise cause a Err(NoMatch) to propagate, instead cause a panic detailing where the error is.
This is probably a bit more involved than I'd wish, as it adds state to the conversion where it didn't exist before. However, here's a rough outline of what needs to change to support this:
- The attribute grammar needs to be adjusted to add the attribute
- The conversion of sequential fields needs to be adjusted for the commit toggle.
Best guess: replace the FromPest::from_pest(inner)? with FromPest::from_pest(inner).map_err(|e| if commit { panic!(..) } else { e })?, and add code to manage the commit variable. We can rely on optimizing it out if it's never set.
https://github.com/pest-parser/ast/blob/db9e2b4d57fe61d85f7d3e768d026f0ec95776a7/derive/src/from_pest/field.rs#L58-L70