[−][src]Function combine::tokens2
pub fn tokens2<C, T, I>(cmp: C, tokens: T) -> Tokens2<C, T, I> where
C: FnMut(T::Item, I::Item) -> bool,
T: Clone + IntoIterator,
I: Stream, 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.
let result = tokens2(|l, r| l.eq_ignore_ascii_case(&r), "abc".chars()) .parse("AbC") .map(|x| x.0.as_str()); assert_eq!(result, Ok("abc")); let result = tokens2( |&l, r| (if l < r { r - l } else { l - r }) <= 2, &b"025"[..] ) .parse(&b"123"[..]) .map(|x| x.0); assert_eq!(result, Ok(&b"025"[..]));