pub fn take<'a, I>(n: usize) -> Parser<'a, I, &'a [I]>
Expand description
Returns a Parser that returns an element of the specified length.
指定された長さの要素を返すParserを返す。
- n: Length of the reading element
- n: 読む要素の長さ
§Example
use std::iter::FromIterator;
use oni_comb_parser_rs::prelude::*;
let text: &str = "abcdef";
let input = text.chars().collect::<Vec<_>>();
let parser: Parser<char, String> = take(3).map(String::from_iter);
let result: ParseResult<char, String> = parser.parse(&input);
assert!(result.is_success());
assert_eq!(result.success().unwrap(), "abc");