Function winnow::combinator::peek
source · pub fn peek<I: Stream, O, E: ParserError<I>, F>(f: F) -> impl Parser<I, O, E>where
F: Parser<I, O, E>,
Expand description
Tries to apply its parser without consuming the input.
§Example
use winnow::combinator::peek;
use winnow::ascii::alpha1;
let mut parser = peek(alpha1);
assert_eq!(parser.parse_peek("abcd;"), Ok(("abcd;", "abcd")));
assert_eq!(parser.parse_peek("123;"), Err(ErrMode::Backtrack(InputError::new("123;", ErrorKind::Slice))));