str_by

Function str_by 

Source
pub fn str_by<Predicate, ItemType>(
    str: &'static str,
    predicate: Predicate,
) -> StrEqualByParser<'static, Predicate, ItemType>
where Predicate: Fn(ItemType, char) -> bool,
Expand description

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

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

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

Output: ()

§Example

use rusty_parser as rp;
use rp::IntoParser;

let hello_parser = rp::str_by("hello", |value:char, ch:char| value.to_ascii_lowercase() == ch );