pub fn value<I, O1, O2, E, F>(val: O1, parser: F) -> impl FnMut(I)
Available on crate feature
mtls
only.Expand description
Returns the provided value if the child parser succeeds.
use nom::combinator::value;
use nom::character::complete::alpha1;
let mut parser = value(1234, alpha1);
assert_eq!(parser("abcd"), Ok(("", 1234)));
assert_eq!(parser("123abcd;"), Err(Err::Error(("123abcd;", ErrorKind::Alpha))));