Provide a way to add #[attributes]
and custom derive to the generated Rule
enum
#566
Labels
#[attributes]
and custom derive to the generated Rule
enum
#566
pest_derive
currently generates aRule
enum without a correspondingenum Rule
anywhere in the code. That way, there is no natural place for inserting attributes and custom derive.My suggestion is that instead of
The code should be like this:
And then, pest would provide a type
GenParser<T>
, that stands for generated parser (note: maybe think about a better name), such thatGenParser<Rule>
would be used exactly likeMyParser
is currently.I believe this would require minimal changes in the generated code: instead of
impl Parser<Rule> for MyParser { .. }
it would generateimpl Parser<Rule> for GenParser<Rule> { ... }
.As an added bonus, the code wouldn't have a hidden
Rule
with no definition or import in the source code, improving discoverability:Rule
is written in the code itself andGenParser
needs to be imported.The text was updated successfully, but these errors were encountered: