From 5e739df3f8d10e79336760025f9e51bc7835a91c Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 4 Sep 2016 17:31:10 +0200 Subject: [PATCH] Replace is_none() -> unwrap() with unwrap_or_else() --- imag-diary/src/create.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/imag-diary/src/create.rs b/imag-diary/src/create.rs index bd17e79e..66818527 100644 --- a/imag-diary/src/create.rs +++ b/imag-diary/src/create.rs @@ -13,13 +13,11 @@ use libimagdiary::result::Result; use util::get_diary_name; pub fn create(rt: &Runtime) { - - let diaryname = get_diary_name(rt); - if diaryname.is_none() { - warn!("No diary selected. Use either the configuration file or the commandline option"); - exit(1); - } - let diaryname = diaryname.unwrap(); + let diaryname = get_diary_name(rt) + .unwrap_or_else(|| { + warn!("No diary selected. Use either the configuration file or the commandline option"); + exit(1) + }); let prevent_edit = rt.cli().subcommand_matches("create").unwrap().is_present("no-edit");