pub fn take_while0<'a, I, F>(f: F) -> Parser<'a, I, &'a [I]>
Expand description
クロージャの結果が真である間は要素を返すParserを返す。
Returns a Parser that returns elements, while the result of the closure is true.
解析結果の長さは必須ではありません。
The length of the analysis result is not required.
§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_while0(|e| match *e {
'a'..='c' => true,
_ => false
}).map(String::from_iter);
let result: ParseResult<char, String> = parser.parse(&input);
assert!(result.is_success());
assert_eq!(result.success().unwrap(), "abc");
use std::iter::FromIterator;
use oni_comb_parser_rs::prelude::*;
let text: &str = "def";
let input = text.chars().collect::<Vec<_>>();
let parser: Parser<char, String> = take_while0(|e| match *e {
'a'..='c' => true,
_ => false
}).map(String::from_iter);
let result: ParseResult<char, String> = parser.parse(&input);
assert!(result.is_success());
assert_eq!(result.success().unwrap(), "");