pub fn peek<I: Clone, F>(
parser: F,
) -> impl Parser<I, Output = <F as Parser<I>>::Output, Error = <F as Parser<I>>::Error>where
F: Parser<I>,
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.parse("abcd;"), Ok(("abcd;", "abcd")));
assert_eq!(parser.parse("123;"), Err(Err::Error(("123;", ErrorKind::Alpha))));