slice_by

Function slice_by 

Source
pub fn slice_by<T, Predicate, ItemType>(
    slice: &'static [T],
    predicate: Predicate,
) -> SliceEqualByParser<'static, T, Predicate, ItemType>
where Predicate: Fn(ItemType, &T) -> bool,
Expand description

Compare the input starts with the given slice. With given equality function.

The closure MUST be Fn(Iterator::Item, &T) -> bool.

for borrowing-safety, the lifetime of slice must be ’static. for non-static slice, use crate::vec_by() instead.

Output: ()

§Example

use rusty_parser as rp;
use rp::IntoParser;

let hello_parser = rp::slice_by(&[104, 101, 108, 108, 111], |value:i32, ch:&i32| value == *ch );