[−][src]Function combine::attempt
pub fn attempt<P>(p: P) -> Try<P> where
P: Parser,
attempt(p)
behaves as p
except it acts as if the parser hadn't consumed any input if p
fails
after consuming input. (alias for try
)
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());
attempt
is an alias for try
. It was added because try
is now a keyword in Rust 2018.