[−][src]Function combine::parser::item::tokens
pub fn tokens<T, I>(tokens: T) -> impl Parser<Input = I, Output = T> where
T: Clone + IntoIterator,
I: Stream,
T::Item: PartialEq<I::Item>,
Parses multiple tokens.
Consumes items from the input and compares them to the values from tokens
using the
comparison function cmp
. Succeeds if all the items from tokens
are matched in the input
stream and fails otherwise with expected
used as part of the error.
let result = tokens("abc".chars()) .parse("abc") .map(|x| x.0.as_str()); assert_eq!(result, Ok("abc"));