Function nom::combinator::recognize[][src]

pub fn recognize<I: Clone + Offset + Slice<RangeTo<usize>>, O, E: ParseError<I>, F>(
    parser: F
) -> impl Fn(I) -> IResult<I, I, E> where
    F: Fn(I) -> IResult<I, O, E>, 

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 parser = recognize(separated_pair(alpha1, char(','), alpha1));

assert_eq!(parser("abcd,efgh"), Ok(("", "abcd,efgh")));
assert_eq!(parser("abcd;"),Err(Err::Error((";", ErrorKind::Char))));