Open CAD97 opened 5 years ago
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:
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.
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 aErr(NoMatch)
to propagate, instead cause a panic detailing where the error is.