Function winnow::combinator::peek
source · pub fn peek<I: Stream, O, E: ParseError<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::character::alpha1;
let mut parser = peek(alpha1);
assert_eq!(parser.parse_next("abcd;"), Ok(("abcd;", "abcd")));
assert_eq!(parser.parse_next("123;"), Err(ErrMode::Backtrack(Error::new("123;", ErrorKind::Slice))));