oni_comb_parser_rs::prelude

Function elm_pred_ref

Source
pub fn elm_pred_ref<'a, I, F>(f: F) -> Parser<'a, I, &'a I>
where F: Fn(&I) -> bool + 'a, I: Element + PartialEq + 'a,
Expand description

Returns a Parser that parses the elements that satisfy the specified closure conditions.(for reference)
指定されたクロージャの条件を満たす要素を解析するParserを返します。(参照版)

  • f: Closure(クロージャ)

§Example

use oni_comb_parser_rs::prelude::*;

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

let parser: Parser<char, &char> = elm_pred_ref(|c| *c == 'x');

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

assert!(result.is_success());
assert_eq!(result.success().unwrap(), &input[0]);