elm_pred_ref

Function elm_pred_ref 

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

Returns a Parser that parses the elements that satisfy the specified closure conditions.(for reference)

  • f: Closure(クロージャ)

§Example


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]);