Function tag

fn tag<T, I, Error: ParseError<I>>(tag: T) -> impl Parser<I, Output = I, Error = Error>
where
    I: Input + Compare<T>,
    T: Input + Clone

Recognizes a pattern.

The input data will be compared to the tag combinator's argument and will return the part of the input that matches the argument.

Example

# use nom::{Err, error::{Error, ErrorKind}, Needed, IResult};
use nom::bytes::streaming::tag;

fn parser(s: &str) -> IResult<&str, &str> {
  tag("Hello")(s)
}

assert_eq!(parser("Hello, World!"), Ok((", World!", "Hello")));
assert_eq!(parser("Something"), Err(Err::Error(Error::new("Something", ErrorKind::Tag))));
assert_eq!(parser("S"), Err(Err::Error(Error::new("S", ErrorKind::Tag))));
assert_eq!(parser("H"), Err(Err::Incomplete(Needed::new(4))));