pub fn peek<I: Clone, O, E: ParseError<I>, F>(
f: F,
) -> impl FnMut(I) -> IResult<I, O, E>where
F: Parser<I, O, E>,
Expand description
Tries to apply its parser without consuming the input.
use nom::combinator::peek;
use nom::character::complete::alpha1;
let mut parser = peek(alpha1);
assert_eq!(parser("abcd;"), Ok(("abcd;", "abcd")));
assert_eq!(parser("123;"), Err(Err::Error(("123;", ErrorKind::Alpha))));