oni_comb_parser_rs::prelude

Function tag

Source
pub fn tag<'a, 'b>(tag: &'b str) -> Parser<'a, char, &'a str>
where 'b: 'a,
Expand description

Returns a Parser that parses a string.
文字列を解析するParserを返す。

  • tag: a string
  • tag: 文字列

§Example

use oni_comb_parser_rs::prelude::*;

let text: &str = "abcdef";
let input = text.chars().collect::<Vec<_>>();

let parser: Parser<char, &str> = tag("abc");

let result: ParseResult<char, &str> = parser.parse(&input);

assert!(result.is_success());
assert_eq!(result.success().unwrap(), "abc");