Try Block

Try block is (at the time of writing) an unstable feature (#![feature(try_blocks)]) to introduce a scope for the ? operator. For example:

let result: Result<i32, ParseIntError> = try {
    "1".parse::<i32>()?
        + "foo".parse::<i32>()?
        + "3".parse::<i32>()?
};

Libraries

There are two crates commonly help Rust error handling. thiserror for library code, and anyhow for application code.

Reference

See Also