Function delimited

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

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

Arguments

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

let mut parser = delimited(tag("("), tag("abc"), tag(")"));

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