pub fn failed_lazy<'a, I, A, F>(f: F) -> Parser<'a, I, A>
Expand description
Returns a Parser that represents the result of the failed parsing.
失敗した解析結果を表すParserを返します。
- f: 失敗した解析結果を返すクロージャ
- f: Closure that returns failed analysis results.
§Example
use oni_comb_parser_rs::prelude::*;
let text: &str = "x";
let input: Vec<char> = text.chars().collect::<Vec<_>>();
let parse_error: ParseError<char> = ParseError::of_in_complete();
let parser: Parser<char, ()> = failed_lazy(|| (parse_error.clone(), CommittedStatus::Committed));
let result: ParseResult<char, ()> = parser.parse(&input);
assert!(result.is_failure());
assert_eq!(result.failure().unwrap(), parse_error);