From 68e7f9af2ff7eec243c0b776f24509be761c0ffa Mon Sep 17 00:00:00 2001 From: "Hatter Jiang@Pixelbook" Date: Sun, 4 Aug 2019 21:58:56 +0800 Subject: [PATCH] match -> unwrap_or_else --- src/main.rs | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0251058..a0d699f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -112,13 +112,9 @@ fn do_with_buildin_arg_builder(first_arg: &str, args: &Vec, builder_name for i in from_index..args.len() { cmd.arg(&args[i]); } - match run_command_and_wait(&mut cmd) { - Err(err) => { - print_message(MessageType::ERROR, &format!("Run build command failed: {}", err)); - return; - }, - Ok(_) => (), - }; + run_command_and_wait(&mut cmd).unwrap_or_else(|err| { + print_message(MessageType::ERROR, &format!("Run build command failed: {}", err)); + }); } fn do_with_buildin_args(args: &Vec) { @@ -222,11 +218,7 @@ fn main() { for i in 1..args.len() { cmd.arg(&args[i]); } - match run_command_and_wait(&mut cmd) { - Err(err) => { - print_message(MessageType::ERROR, &format!("Run build command failed: {}", err)); - return; - }, - Ok(_) => (), - }; + run_command_and_wait(&mut cmd).unwrap_or_else(|err| { + print_message(MessageType::ERROR, &format!("Run build command failed: {}", err)); + }); } \ No newline at end of file