[][src]Function combine::attempt

pub fn attempt<Input, P>(p: P) -> Try<P> where
    Input: Stream,
    P: Parser<Input>, 

attempt(p) behaves as p except it always acts as p peeked instead of committed on its parse.

let mut p = attempt(string("let"))
    .or(string("lex"));
let result = p.parse("lex").map(|x| x.0);
assert_eq!(result, Ok("lex"));
let result = p.parse("aet").map(|x| x.0);
assert!(result.is_err());