From 1bb6f452e93149f67f8d03abf2fc2a11a9ce4a5c Mon Sep 17 00:00:00 2001 From: flip1995 Date: Tue, 27 Aug 2019 10:05:34 +0200 Subject: [PATCH] [No-auto] bin/domain/diary: Fix Clippy warnings Signed-off-by: flip1995 Signed-off-by: Matthias Beyer --- bin/domain/imag-diary/src/create.rs | 6 ++--- bin/domain/imag-diary/src/main.rs | 36 ++++++++++++++--------------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/bin/domain/imag-diary/src/create.rs b/bin/domain/imag-diary/src/create.rs index b7da6c16..8a3f80a3 100644 --- a/bin/domain/imag-diary/src/create.rs +++ b/bin/domain/imag-diary/src/create.rs @@ -126,7 +126,7 @@ fn create_id_from_clispec(create: &ArgMatches, timed_type: Timed) -> NaiveDateTi .map_err(|_| warn!("Could not parse minute: '{}'", s)) .ok() }) - .unwrap_or(ndt.minute()); + .unwrap_or_else(|| ndt.minute()); ndt.with_minute(min) .unwrap_or_else(|| { @@ -146,7 +146,7 @@ fn create_id_from_clispec(create: &ArgMatches, timed_type: Timed) -> NaiveDateTi .map_err(|_| warn!("Could not parse minute: '{}'", s)) .ok() }) - .unwrap_or(ndt.minute()); + .unwrap_or_else(|| ndt.minute()); let sec = create .value_of("second") @@ -156,7 +156,7 @@ fn create_id_from_clispec(create: &ArgMatches, timed_type: Timed) -> NaiveDateTi .map_err(|_| warn!("Could not parse second: '{}'", s)) .ok() }) - .unwrap_or(ndt.second()); + .unwrap_or_else(|| ndt.second()); ndt.with_minute(min) .unwrap_or_else(|| { diff --git a/bin/domain/imag-diary/src/main.rs b/bin/domain/imag-diary/src/main.rs index cf5c3fd2..bc1c9a1f 100644 --- a/bin/domain/imag-diary/src/main.rs +++ b/bin/domain/imag-diary/src/main.rs @@ -79,25 +79,23 @@ fn main() { "Personal Diary/Diaries", ui::build_ui); - rt.cli() - .subcommand_name() - .map(|name| { - debug!("Call {}", name); - match name { - "diaries" => diaries(&rt), - "create" => create(&rt), - "delete" => delete(&rt), - "list" => list(&rt), - "view" => view(&rt), - other => { - debug!("Unknown command"); - let _ = rt.handle_unknown_subcommand("imag-diary", other, rt.cli()) - .map_err_trace_exit_unwrap() - .code() - .map(::std::process::exit); - }, - } - }); + if let Some(name) = rt.cli().subcommand_name() { + debug!("Call {}", name); + match name { + "diaries" => diaries(&rt), + "create" => create(&rt), + "delete" => delete(&rt), + "list" => list(&rt), + "view" => view(&rt), + other => { + debug!("Unknown command"); + let _ = rt.handle_unknown_subcommand("imag-diary", other, rt.cli()) + .map_err_trace_exit_unwrap() + .code() + .map(::std::process::exit); + }, + } + } } fn diaries(rt: &Runtime) {