I could not get this to compile. #[derive(Parser)] errors out with cannot find deriver macro Parser in this scope, despite pest_derive being in Cargo.toml and the use statement bringing Parser in.
I discovered this was for 2 reasons: 1) there was a typo in the .pest file that made the proc crash causing a compiler error; and 2) you need `#[derive(pest_derive::Parser)] to differentiate it from pest::Parser.
You still need this block for Pest to generate the code for you. Omitting the block exactly reproduced the issue you had. You don't need the extern crate pest; statement though.
You don't at all. #[macro_use] is not required in 2018 edition. I was able to compile it fine without it using only the 2nd change I described above. To be clear, the typo I described before was of my own doing and nothing to do with your code.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I could not get this to compile.
#[derive(Parser)]
errors out with cannot find deriver macroParser
in this scope, despitepest_derive
being in Cargo.toml and the use statement bringing Parser in.I discovered this was for 2 reasons: 1) there was a typo in the .pest file that made the proc crash causing a compiler error; and 2) you need `#[derive(pest_derive::Parser)] to differentiate it from pest::Parser.
Hi, thanks for letting me know. You have to import the
Parser
trait frompest
module withuse pest::Parser
before you can derive it.Or if you have done the above, please check the following block:
You don't have to use
pest_derive
directly, but you need the#[macro_use]
attribute applied to the extern statement.You don't need the #[macro_use] attribute any more for 2018 edition of Rust.
You still need this block for Pest to generate the code for you. Omitting the block exactly reproduced the issue you had. You don't need the
extern crate pest;
statement though.You don't at all.
#[macro_use]
is not required in 2018 edition. I was able to compile it fine without it using only the 2nd change I described above. To be clear, the typo I described before was of my own doing and nothing to do with your code.