Function combine::try
[−]
[src]
pub fn try<P>(p: P) -> Try<P> where
P: Parser,
try(p)
behaves as p
except it acts as if the parser hadn't consumed any input if p
fails after
consuming input.
let mut p = try(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());