Function chomp::parsers::satisfy [] [src]

pub fn satisfy<I: Copy, F>(i: Input<I>, f: F) -> SimpleResult<I, I> where F: FnOnce(I) -> bool

Matches an item using f, the item is returned if f yields true, otherwise this parser fails.

If the buffer length is 0 this parser is considered incomplete.

use chomp::{parse_only, satisfy};

assert_eq!(parse_only(|i| satisfy(i, |c| c == b'a'), b"abc"), Ok(b'a'));