Function terminated

fn terminated<I, O, E: ParseError<I>, F, G>(first: F, second: G) -> impl Parser<I, Output = O, Error = E>
where
    F: Parser<I, Output = O, Error = E>,
    G: Parser<I, Error = E>

Gets an object from the first parser, then matches an object from the second parser and discards it.

Arguments

# use nom::{Err, error::ErrorKind, Needed, Parser};
# use nom::Needed::Size;
use nom::sequence::terminated;
use nom::bytes::complete::tag;

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

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