Use Result::flatten in catch_with_exit_code
This commit is contained in:
parent
f4d794ea0b
commit
7e3f5f858d
1 changed files with 2 additions and 2 deletions
|
@ -12,6 +12,7 @@
|
||||||
#![feature(lazy_cell)]
|
#![feature(lazy_cell)]
|
||||||
#![feature(let_chains)]
|
#![feature(let_chains)]
|
||||||
#![feature(panic_update_hook)]
|
#![feature(panic_update_hook)]
|
||||||
|
#![feature(result_flattening)]
|
||||||
#![recursion_limit = "256"]
|
#![recursion_limit = "256"]
|
||||||
#![deny(rustc::untranslatable_diagnostic)]
|
#![deny(rustc::untranslatable_diagnostic)]
|
||||||
#![deny(rustc::diagnostic_outside_of_impl)]
|
#![deny(rustc::diagnostic_outside_of_impl)]
|
||||||
|
@ -1249,8 +1250,7 @@ pub fn catch_fatal_errors<F: FnOnce() -> R, R>(f: F) -> Result<R, ErrorGuarantee
|
||||||
/// Variant of `catch_fatal_errors` for the `interface::Result` return type
|
/// Variant of `catch_fatal_errors` for the `interface::Result` return type
|
||||||
/// that also computes the exit code.
|
/// that also computes the exit code.
|
||||||
pub fn catch_with_exit_code(f: impl FnOnce() -> interface::Result<()>) -> i32 {
|
pub fn catch_with_exit_code(f: impl FnOnce() -> interface::Result<()>) -> i32 {
|
||||||
let result = catch_fatal_errors(f).and_then(|result| result);
|
match catch_fatal_errors(f).flatten() {
|
||||||
match result {
|
|
||||||
Ok(()) => EXIT_SUCCESS,
|
Ok(()) => EXIT_SUCCESS,
|
||||||
Err(_) => EXIT_FAILURE,
|
Err(_) => EXIT_FAILURE,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue