Function verify

fn verify<I: Clone, O2, E: ParseError<I>, F, G>(first: F, second: G) -> impl Parser<I, Output = <F as Parser<I>>::Output, Error = E>
where
    F: Parser<I, Error = E>,
    G: Fn(&O2) -> bool,
    <F as Parser<I>>::Output: Borrow<O2>,
    O2: ?Sized

Returns the result of the child parser if it satisfies a verification function.

The verification function takes as argument a reference to the output of the parser.

# use nom::{Err,error::ErrorKind, IResult, Parser};
use nom::combinator::verify;
use nom::character::complete::alpha1;
# fn main() {

let mut parser = verify(alpha1, |s: &str| s.len() == 4);

assert_eq!(parser.parse("abcd"), Ok(("", "abcd")));
assert_eq!(parser.parse("abcde"), Err(Err::Error(("abcde", ErrorKind::Verify))));
assert_eq!(parser.parse("123abcd;"),Err(Err::Error(("123abcd;", ErrorKind::Alpha))));
# }