Is there any way to return from a function from inside a closure?
问题 I have the following simplified code: fn f() -> i32 { let a = some_result.unwrap_or_else(|_| { return 1; // want to return this value from f <------------- }); } I want to return the value 1 from the whole function f in this specific error case but I can't figure out how to do it from within a closure. If I instead use a match expression, it works fine as follows: fn f() -> i32 { let a = match some_result { Ok(result) => result, Err(_) => { return 1; }, }; } However, this makes the code