Function chomp::parsers::scan [] [src]

pub fn scan<I: Input, S, F>(i: I, s: S, f: F) -> SimpleResult<I, I::Buffer> where
    F: FnMut(S, I::Token) -> Option<S>, 

The predicate consumes and transforms a state argument, this parser will match everything until the predicate returns None.

use chomp::prelude::{parse_only, scan};

let p = |i| scan(i, false, |s, c| match (s, c) {
    (true, b'/') => None,
    (_,    b'*') => Some(true),
    (_, _)       => Some(false),
});

assert_eq!(parse_only(p, b"/*test*of*scan*/ foo"), Ok(&b"/*test*of*scan*"[..]));