Function nom::combinator::value[][src]

pub fn value<I, O1: Clone, O2, E: ParseError<I>, F>(
    val: O1,
    parser: F
) -> impl Fn(I) -> IResult<I, O1, E> where
    F: Fn(I) -> IResult<I, O2, E>, 

returns the provided value if the child parser succeeds

use nom::combinator::value;
use nom::character::complete::alpha1;

let parser = value(1234, alpha1);

assert_eq!(parser("abcd"), Ok(("", 1234)));
assert_eq!(parser("123abcd;"), Err(Err::Error(("123abcd;", ErrorKind::Alpha))));