This is interesting because with labeled break value it could be a good alternative to try blocks:
// With `try` blocks
let z = try {
let x = foo()?;
let y = bar()?;
x + y
}
// With this proposal
let z = 'a: {
let x = foo() 'a ?;
let y = bar() 'a ?;
Ok(x + y)
}
I definitely would prefer this over try, since it seems to be easier to implement, easier to understand, and I’ve never seen too much use cases that worth to introduce try syntax.
Additionally, it seems to be more flexible:
let z = 'a: {
let x = foo() 'a ?;
let y = bar() 'a ?;
validate(x, y)?;
Ok(x + y)
}