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::{Input, satisfy_with}; let i = Input::new(b"testing"); let r = satisfy_with(i, |c| AsciiExt::to_ascii_uppercase(&c), |c| c == b'T'); assert_eq!(r.unwrap(), b'T')