pub fn take_till1<'a, I, F>(f: F) -> Parser<'a, I, &'a [I]>
Expand description
Returns a Parser that returns a sequence up to either the end element or the element that matches the condition.
条件に一致する要素もしくは最後の要素までの連続を返すParserを返す。
解析結果の長さは1要素以上必要です。
The length of the analysis result must be at least one element.
§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_till1(|e| matches!(*e, 'c')).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_till1(|e| matches!(*e, 'c')).map(String::from_iter);
let result: ParseResult<char, String> = parser.parse(&input);
assert!(result.is_failure());
assert_eq!(result.failure().unwrap(), ParseError::of_in_complete());