Function chomp::parsers::take_while1 [] [src]

pub fn take_while1<I: Copy, F>(i: Input<I>, f: F) -> SimpleResult<I, &[I]> where F: Fn(I) -> bool

Matches all items while f returns true, if at least one item matched this parser succeeds and returns a slice of all the matched items.

If no failure can be found the parser will be considered to be incomplete as there might be more input which needs to be matched. If zero items were matched an error will be returned.

use chomp::{Input, take_while1};

let p = Input::new(b"abcdcba");

assert_eq!(take_while1(p, |c| c == b'a' || c == b'b').unwrap(), b"ab");