Function pear::parsers::take_while_window[][src]

pub fn take_while_window<I, F>(
    input: &mut Pear<I>,
    n: usize,
    f: F
) -> Result<I::Many, I> where
    I: Input + Rewind,
    F: FnMut(&I::Slice) -> bool
Expand description

Consumes tokens while cond matches on a window of tokens of size n and returns all of the tokens prior to the first failure to match. For example, given a string of “aaab” and a size 2 window predicate of window == "aa", the return value is "aa" as the first failure to match is at "ab".

Always succeeds. If no tokens match, the result will be empty. If there are fewer than n tokens, takes all tokens and returns them.