Function chomp::parsers::run_scanner [] [src]

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

Like scan but generalized to return the final state of the scanner.

use chomp::{parse_only, run_scanner};

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

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