Function nom::bytes::streaming::tag [−][src]
pub fn tag<'a, T: 'a, Input: 'a, Error: ParseError<Input>>(
tag: T
) -> impl Fn(Input) -> IResult<Input, Input, Error> where
Input: InputTake + Compare<T>,
T: InputLength + 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::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(("Something", ErrorKind::Tag)))); assert_eq!(parser(""), Err(Err::Incomplete(Needed::Size(5))));