macro_rules! try_block {
{ $($token:tt)* } => { ... };
}
Expand description
Macro for the receiving end of a ?
operation.
// Note: this fails without explicitly specifying the error type.
let y: Result<_, std::num::ParseIntError> = try_block! {
"1".parse::<i32>()? + "2".parse::<i32>()?
};
assert_eq!(y, Ok(3));