Skip to content
New issue

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

FlatMap does not properly implement Parser #1731

Open
hsfzxjy opened this issue Feb 16, 2024 · 0 comments
Open

FlatMap does not properly implement Parser #1731

hsfzxjy opened this issue Feb 16, 2024 · 0 comments

Comments

@hsfzxjy
Copy link

hsfzxjy commented Feb 16, 2024

  • Rust version : 1.76.0
  • nom version : 7.1.3
  • nom compilation features used: std

Example test case:

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=38ea81309c5b6c70c5ded853cbb30a34

use nom::character::complete::anychar;
use nom::Parser;

fn main() {
    anychar.flat_map(|_| anychar).parse("ab").unwrap();
}

G: FnMut(O) -> H,

impl<'a, I, O1, O2, E, F: Parser<I, O1, E>, G: Fn(O1) -> H, H: Parser<I, O2, E>> Parser<I, O2, E>

Seems like a mismatch between above lines (notice Fn vs FnMut), making the flat_map unusable.

However I saw it fixed in current main branch

G: FnMut(<F as Parser<I>>::Output) -> H,

Will this fix also be ported to 7.x?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant