From afffde7f2ca7ad33933ba2a7a50ebb6a89bdf765 Mon Sep 17 00:00:00 2001 From: "Hatter Jiang@Pixelbook" Date: Sun, 4 Aug 2019 22:07:00 +0800 Subject: [PATCH] match -> unwrap_or_else --- src/local_util.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/local_util.rs b/src/local_util.rs index 91b8d8e..fa3f450 100644 --- a/src/local_util.rs +++ b/src/local_util.rs @@ -116,11 +116,8 @@ pub fn init_home_dir(home_sub_dir: &str) { pub fn init_dir(dir: &str) { if ! Path::new(dir).exists() { - match fs::create_dir_all(dir) { - Ok(_) => (), - Err(err) => { - print_message(MessageType::ERROR, &format!("Init dir {} failed: {}", dir, err)); - }, - } + fs::create_dir_all(dir).unwrap_or_else(|err| { + print_message(MessageType::ERROR, &format!("Init dir {} failed: {}", dir, err)); + }); } }