Function snarkvm_console_program::string::terminated
pub fn terminated<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>,Expand description
Gets an object from the first parser, then matches an object from the second parser and discards it.
Arguments
firstThe first parser to apply.secondThe second parser to match an object.
use nom::sequence::terminated;
use nom::bytes::complete::tag;
let mut 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))));