You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not sure if this is a bug, but it seems like it should work. This code fails to compile:
externcrate combine;use combine::{digit, letter, sep_by, token,Parser,ParserExt};fnmain(){let p = sep_by::<Vec<_>,_,_>(digit(),token(','));let result = letter().or(p).parse("1,2,3");}
With this error:
type mismatch resolving `<&str as combine::primitives::Stream>::Item == collections::vec::Vec<char>`:
expected char,
found struct `collections::vec::Vec` [E0271]
src/main.rs:6let result = letter().or(p).parse("1,2,3");
However, this works just fine:
externcrate combine;use combine::{digit, letter, token,Parser,ParserExt};fnmain(){let result = letter().or(digit()).parse("1,2,3");}
The text was updated successfully, but these errors were encountered:
In this case the error message is a bit confusing but the issue is that letter() outputs a char while sep_by outputs a Vec and or requires that both parsers outputs the same type. I am not sure what you want to output in this case but this thread about an expression parser might help as well #54
Thanks for the reply. Ultimately, what I'm trying to do is parse a string consisting of letters with optional arguments lists, like this: ABA(1, 2)C(3)DE(4, 5, 6)C. Reading over the thread you linked, it looks like I'll want to make an enum to represent both options. Thanks!
Not sure if this is a bug, but it seems like it should work. This code fails to compile:
With this error:
However, this works just fine:
The text was updated successfully, but these errors were encountered: