pub fn string_cmp<'a, C, Input>(
s: &'static str,
cmp: C
) -> impl Parser<Input, Output = &'a str> where
C: FnMut(char, char) -> bool,
Input: Stream<Token = char>,
Input::Error: ParseError<Input::Token, Input::Range, Input::Position>,
Expand description
Parses the string s
, using cmp
to compare each character.
let result = string_cmp("rust", |l, r| l.eq_ignore_ascii_case(&r))
.parse("RusT")
.map(|x| x.0);
assert_eq!(result, Ok("rust"));