string_by

Function string_by 

Source
pub fn string_by<Predicate, ItemType>(
    str: String,
    predicate: Predicate,
) -> StringEqualByParser<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.

This will copy all the characters into String, so lifetime belongs to the parser itself.

Output: ()

ยงExample

use rusty_parser as rp;
use rp::IntoParser;

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