Function chomp::parsers::satisfy_with [] [src]

pub fn satisfy_with<I: Copy, T: Clone, F, P>(i: Input<I>, f: F, p: P) -> SimpleResult<I, T> where F: FnOnce(I) -> T, P: FnOnce(T) -> bool

Reads a single token, applies the transformation F and then succeeds with the transformed valeue if the predicate P yields true on this transformed value.

use std::ascii::AsciiExt;

use chomp::{parse_only, satisfy_with};

let r = parse_only(
    |i| satisfy_with(i, |c| AsciiExt::to_ascii_uppercase(&c), |c| c == b'T'),
    b"testing");

assert_eq!(r, Ok(b'T'));