tag

Function tag 

Source
pub fn tag<'input, 'tag>(
    tag: &'tag str,
) -> impl UpParser<'input, &'input str> + 'tag
Expand description

Takes the string tag from the input.

use parse_up::{UpParser as _, tag, util::{yes_and, go_on, oops}};
assert_eq!(
    tag("hello").parse(""),
    go_on(["hello"]),
);
assert_eq!(
    tag("hello").parse("hell"),
    go_on(["o"]),
);
assert_eq!(
    tag("hello").parse("hello"),
    yes_and("hello", ""),
);
assert_eq!(
    tag("hello").parse("hello, world!"),
    yes_and("hello", ", world!"),
);
assert_eq!(
    tag("hello").parse("world"),
    oops("expected hello, not world"),
);