oni_comb_parser_rs::prelude

Function successful_lazy

Source
pub fn successful_lazy<'a, I, A, F>(f: F) -> Parser<'a, I, A>
where I: 'a, F: Fn() -> A + 'a, A: 'a,
Expand description

Returns a Parser representing the successful parsing result.
成功した解析結果を表すParserを返します。

  • f: a closure that returns the parsed result value.
  • f: 解析結果の値を返すクロージャ

§Example

use oni_comb_parser_rs::prelude::*;

let text: &str = "x";
let input: Vec<char> = text.chars().collect::<Vec<_>>();

let parser: Parser<char, char> = successful_lazy(|| 'a');

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

assert!(result.is_success());
assert_eq!(result.success().unwrap(), 'a');