Function nom::sequence::terminated [−][src]
pub fn terminated<I, O1, O2, E: ParseError<I>, F, G>(
first: F,
second: G
) -> impl Fn(I) -> IResult<I, O1, E> where
F: Fn(I) -> IResult<I, O1, E>,
G: Fn(I) -> IResult<I, O2, E>,
Gets an object from the first parser, then matches an object from the second parser and discards it.
Arguments
first
The first parser to apply.second
The second parser to match an object.
use nom::sequence::terminated; use nom::bytes::complete::tag; let parser = terminated(tag("abc"), tag("efg")); assert_eq!(parser("abcefg"), Ok(("", "abc"))); assert_eq!(parser("abcefghij"), Ok(("hij", "abc"))); assert_eq!(parser(""), Err(Err::Error(("", ErrorKind::Tag)))); assert_eq!(parser("123"), Err(Err::Error(("123", ErrorKind::Tag))));