Function rocket::mtls::oid::asn1_rs::nom::sequence::preceded

source ·
pub fn preceded<I, O1, O2, E, F, G>(first: F, second: G) -> impl FnMut(I)
where E: ParseError<I>, F: Parser<I, O1, E>, G: Parser<I, O2, E>,
Available on crate feature mtls only.
Expand description

Matches an object from the first parser and discards it, then gets an object from the second parser.

§Arguments

  • first The opening parser.
  • second The second parser to get object.
use nom::sequence::preceded;
use nom::bytes::complete::tag;

let mut parser = preceded(tag("abc"), tag("efg"));

assert_eq!(parser("abcefg"), Ok(("", "efg")));
assert_eq!(parser("abcefghij"), Ok(("hij", "efg")));
assert_eq!(parser(""), Err(Err::Error(("", ErrorKind::Tag))));
assert_eq!(parser("123"), Err(Err::Error(("123", ErrorKind::Tag))));