We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dispatch!
1.81.0
0.6.13
fn main() { use winnow::combinator::{dispatch, empty, fail, preceded}; use winnow::prelude::*; use winnow::token::any; fn escaped(input: &mut &str) -> PResult<char> { preceded('\\', escape_seq_char).parse_next(input) } fn escape_seq_char(input: &mut &str) -> PResult<char> { dispatch! {any; 'b' => empty.value('\u{8}'), #[cfg(unix)] '"' => empty.value('"'), _ => fail::<_, char, _>, } .parse_next(input) } assert_eq!(escaped.parse_peek("\\b\""), Ok(("\"", '\u{8}'))); }
cargo run
Compiling tmp-unpavh v0.1.0 (/home/zeenix/.cache/cargo-temp/tmp-UNpAvH) error: no rules expected the token `#` --> src/main.rs:13:13 | 13 | #[cfg(unix)] | ^ no rules expected this token in macro call | note: while trying to match meta-variable `$pat:pat` --> /home/zeenix/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winnow-0.6.20/src/macros/dispatch.rs:43:30 | 43 | ($match_parser: expr; $( $pat:pat $(if $pred:expr)? => $expr: expr ),+ $(,)? ) => { | ^^^^^^^^ warning: unused imports: `empty` and `fail` --> src/main.rs:2:40 | 2 | use winnow::combinator::{dispatch, empty, fail, preceded}; | ^^^^^ ^^^^ | = note: `#[warn(unused_imports)]` on by default warning: unused import: `winnow::token::any` --> src/main.rs:4:9 | 4 | use winnow::token::any; | ^^^^^^^^^^^^^^^^^^ warning: `tmp-unpavh` (bin "tmp-unpavh") generated 2 warnings error: could not compile `tmp-unpavh` (bin "tmp-unpavh") due to 1 previous error; 2 warnings emitted
Code should compile and run successfully (on unix systems).
@epage Hello from China. :)
The text was updated successfully, but these errors were encountered:
#[...]
Successfully merging a pull request may close this issue.
Please complete the following tasks
rust version
1.81.0
winnow version
0.6.13
Minimal reproducible code
Steps to reproduce the bug with the above code
cargo run
Actual Behaviour
Expected Behaviour
Code should compile and run successfully (on unix systems).
Additional Context
@epage Hello from China. :)
The text was updated successfully, but these errors were encountered: