Function combine::try
[−]
[src]
pub fn try<P>(p: P) -> Try<P> where P: Parser
Try acts as p
except it acts as if the parser hadn't consumed any input
if p
returns an error 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());