This works great for producing values but not error / None handling. Although the closure can capture variables, it's its own function scope and so things like returning and breaking from above loops doesn't work. For example, the following function
fn example() -> i32 {
let x = || -> i32 {
return 1;
}();
println!("{x}");
2
}
will always print 1 and return 2. Execution is not halted and there's no way to cause a calling function to return other than to return something that the caller would error handle on which means you'd be doing if-let-ing and matching anyways. The syntax I was referring to in the post is a fancy way of using the ?
operator in that you map the error received into an error to pass upwards.