Function combine::combinator::recognize [] [src]

pub fn recognize<F, P>(parser: P) -> Recognize<F, P> where
    P: Parser,
    F: FromIterator<<P::Input as StreamOnce>::Item>, 

Constructs a parser which returns the tokens parsed by parser accumulated in F: FromIterator<P::Input::Item> instead of P::Output.

use combine::Parser;
use combine::combinator::{skip_many1, token, recognize};
use combine::char::digit;

let mut parser = recognize((skip_many1(digit()), token('.'), skip_many1(digit())));
assert_eq!(parser.parse("123.45"), Ok(("123.45".to_string(), "")));
assert_eq!(parser.parse("123.45"), Ok(("123.45".to_string(), "")));