Skip to content

Moving parser into the return closure makes the return function FnOnce #753

Answered by epage
idealseal asked this question in Q&A
Discussion options

You must be logged in to vote

My first question is about the trait bounds: Is it right to always add more trait bounds (for Compare) depending on what I throw in the body of the block? Say I want to ignore the leading group of characters using a string slice

If you don't have to be generic, don't.

When you need to be generic, yes, you need to add each bound. We tried to consolidate as many traits as possible to reduce this but there is only so much that can be done. You can see winnow doing this in parsers like float

The second question is about the body of the any_of parser. The code doesn't compile since the parameter of the surrounding function is moved into the closure making the closure a FnOnce. Is there any …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by idealseal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants