Function chomp::parsers::satisfy_with
[−]
[src]
pub fn satisfy_with<I: Input, T: Clone, F, P>(
i: I,
f: F,
p: P
) -> SimpleResult<I, T> where
F: FnOnce(I::Token) -> 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::prelude::{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'));