Can this just be done as a lambda that is immediately evaluated? It's just much more verbose.
let x = (|| -> Result<i32, std::num::ParseIntError> {
Ok("1".parse::<i32>()?
+ "2".parse::<i32>()?
+ "3".parse::<i32>()?)
})();Wouldn't that also move any referenced variables too? Unlike the block example that would make this code not identical to what it's replacing.
My instinct is this would get hairy much faster if you want to actually close over variables compared to using a block.
That prevents other control flow mechanisms (return, break) from operating past the function boundary. In general, I avoid single-callsite functions as much as possible (including the iterator api) for this reason.