Function combine::parser::range::recognize_with_value [] [src]

pub fn recognize_with_value<P>(parser: P) -> RecognizeWithValue<P> where
    P: Parser,
    P::Input: RangeStream,
    <P::Input as StreamOnce>::Range: Range

Zero-copy parser which returns a pair: (consumed input range, parsed value).

let mut parser = recognize_with_value((
    skip_many1(digit()),
    optional((try(char('.')), skip_many1(digit()))),
).map(|(_, opt)| opt.is_some()));

assert_eq!(parser.parse("1234!"), Ok((("1234", false), "!")));
assert_eq!(parser.parse("1234.0001!"), Ok((("1234.0001", true), "!")));
assert!(parser.parse("!").is_err());
assert!(parser.parse("1234.").is_err());