oni_comb_parser_rs::prelude

Function seq

Source
pub fn seq<'a, 'b, I>(seq: &'b [I]) -> Parser<'a, I, &'a [I]>
where I: PartialEq + Debug + 'a, 'b: 'a,
Expand description

Returns a Parser that parses a sequence of elements.
要素の列を解析するParserを返す。

§Example

use std::iter::FromIterator;
use oni_comb_parser_rs::prelude::*;

let text: &str = "abc";
let input = text.as_bytes();

let parser: Parser<u8, &str> = seq(b"abc").collect().map_res(std::str::from_utf8);

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

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