pub fn recognize_with_value<Input, P>(parser: P) -> RecognizeWithValue<P> where
P: Parser<Input>,
Input: RangeStream,
<Input as StreamOnce>::Range: Range,
Expand description
Zero-copy parser which returns a pair: (committed input range, parsed value).
combinator::recognize_with_value
is a non-RangeStream
alternative.
let mut parser = recognize_with_value((
skip_many1(digit()),
optional((attempt(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());