Function rusty_parser::check

source ·
pub fn check<CheckItem, Input>(
    closure: CheckItem
) -> SingleCheckParser<CheckItem, Input>
where CheckItem: Fn(Input) -> bool,
Expand description

Check single item with the given closure.

The closure must be: Fn(Iterator::Item) -> bool

Output: (Iterator::Item,)

§Example

use rusty_parser as rp;
use rp::IntoParser;

let parser = rp::check( |ch:char| ch.is_alphabetic() );
let res = rp::parse( &parser, "hello".chars() );

let parser = rp::check( |ch:&i32| ch == &1 );
let res = rp::parse( &parser, (&[1,2,3]).iter() );