Function rocket::mtls::oid::asn1_rs::nom::combinator::value

source ยท
pub fn value<I, O1, O2, E, F>(val: O1, parser: F) -> impl FnMut(I)
where O1: Clone, E: ParseError<I>, F: Parser<I, O2, E>,
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))));