oni_comb_parser_rs::prelude

Function failed_with_uncommit

Source
pub fn failed_with_uncommit<'a, I, A>(
    value: ParseError<'a, I>,
) -> Parser<'a, I, A>
where I: Clone + 'a, A: 'a,
Expand description

Returns a Parser that returns failed parsing results and does not commit.
失敗した解析結果を返しコミットしないParserを返します。

§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_with_uncommit(parse_error.clone());

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

assert!(result.is_failure());
assert_eq!(result.committed_status().unwrap(), CommittedStatus::Uncommitted);

assert_eq!(result.failure().unwrap(), parse_error);