mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-22 13:38:43 +00:00
Refactor: Use Result::map_or_else
in main
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
b6245bcf4b
commit
903c9f5591
1 changed files with 6 additions and 8 deletions
14
src/main.rs
14
src/main.rs
|
@ -120,15 +120,13 @@ fn main() -> MainExit {
|
|||
let done = start.elapsed();
|
||||
debug!("run time: {done:?}");
|
||||
|
||||
result
|
||||
.map(|res| {
|
||||
res.map(|_| MainExit::Success(done)).unwrap_or_else(|err| {
|
||||
err.downcast::<BinstallError>()
|
||||
.map(MainExit::Error)
|
||||
.unwrap_or_else(MainExit::Report)
|
||||
})
|
||||
result.map_or_else(MainExit::JoinErr, |res| {
|
||||
res.map(|_| MainExit::Success(done)).unwrap_or_else(|err| {
|
||||
err.downcast::<BinstallError>()
|
||||
.map(MainExit::Error)
|
||||
.unwrap_or_else(MainExit::Report)
|
||||
})
|
||||
.unwrap_or_else(MainExit::JoinErr)
|
||||
})
|
||||
}
|
||||
|
||||
async fn entry() -> Result<()> {
|
||||
|
|
Loading…
Add table
Reference in a new issue