pub fn recognize<I: Clone + Offset + Input, E: ParseError<I>, F>(
parser: F,
) -> impl Parser<I, Output = I, Error = E>where
F: Parser<I, Error = E>,
Expand description
If the child parser was successful, return the consumed input as produced value.
use nom::combinator::recognize;
use nom::character::complete::{char, alpha1};
use nom::sequence::separated_pair;
let mut parser = recognize(separated_pair(alpha1, char(','), alpha1));
assert_eq!(parser.parse("abcd,efgh"), Ok(("", "abcd,efgh")));
assert_eq!(parser.parse("abcd;"),Err(Err::Error((";", ErrorKind::Char))));