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

the trait bound RangeInclusive<char>: FindToken<_> is not satisfied #1783

Open
drdozer opened this issue Nov 11, 2024 · 2 comments
Open

the trait bound RangeInclusive<char>: FindToken<_> is not satisfied #1783

drdozer opened this issue Nov 11, 2024 · 2 comments

Comments

@drdozer
Copy link

drdozer commented Nov 11, 2024

I am not sure if I am using the API incorrectly, or if I have found an edge case that's not yet implemented. I was hoping to be able to write something like this:

    fn parser(s: &str) -> IResult<&str, Self> {
        let (f, file) = nom::character::complete::one_of('a'..='h')(s)?;
        let (r, rank) = nom::character::complete::one_of('1'..='8')(f)?;
        Ok(Square { rank, file })
    }

However, I can't pass in a char range to one_of. I am not quite sure what I should use as an alternative, other than enumerating the characters.

@epage
Copy link
Contributor

epage commented Nov 11, 2024

If you look at the definition of one_of, it takes a FindToken. There is not a FindToken implementation for any of the range types, only different kinds of slice and array types.

I had proposed range types but that was part of a larger effort that stalled out.

@drdozer
Copy link
Author

drdozer commented Nov 14, 2024

OK. I ended up using the predicate test, using the range contains method. But it is a bit verbose, and less declarative. Thanks.

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

2 participants