Closed mainrs closed 4 years ago
You need to set the Output
type of comment_start_token
for the current error at least, I think it should be
fn comment_start_token<I>() -> impl Parser<I, Output = char>
Hard to say at a glance what any errors are other than that but this line
assert_eq!(result, Ok(((), ""))); // <---- error
Would then fail since the result will now contain a char
so you need to change the ()
to a char
I didn't set an output because I wanted the function to consume
the token and not bother with it anymore. I mainly used nom
up until now but wanted to give combine
a try, since the error messages are more user friendly.
That being said, I thought that token
would be similar to nom::take
: It consumes the output. I will try your suggestion. If there isn't something like take I can simply map over it and ignore the value I guess :)
If you don't care about the output you should specify ()
and map
the output to ()
(like you do in begin_of_line_comment
). Otherwise, if you do not specify it, rust will assume that the output is an "opaque" type and it will consider that "opaque" type to only be identical to itself and you can't compare, debug print or do anything else with it.
Ah ok, thanks you very much!
Hey! I am new to the library and not sure where to ask this question. I wanted to write a comment line parser. However, I get a compilation error that I do not understand. Inside of
begin_of_line_comment
, when using thecomment_start_token
parser, the compilation fails. If I pass down the choices parser instead of callingcomment_start_token
, the function compiles. Looks like Rust can't correctly deduce the type. I tried to manually set the Output type but to be honest I miserably failed to somehow specify the correct one.Error: