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

pub fn scan<I: Copy, S, F>(i: Input<I>, s: S, f: F) -> SimpleResult<I, &[I]> where F: FnMut(S, I) -> Option<S>

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

use chomp::{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*"[..]));