From 866feb296652bb99cdb8bbc118638bd075bb1915 Mon Sep 17 00:00:00 2001 From: arnavb11 Date: Fri, 11 Jan 2019 14:07:27 +0000 Subject: [PATCH] Refactor error handling into a if-let --- src/main.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index cdd6e91..b59cab8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -268,13 +268,11 @@ fn main() { let _ = ansi_term::enable_ansi_support(); let result = run(); - match result { - Err(err) => { - // The whitespace is being removed from the right because - // clap errors add a newline to the end of the output already - eprintln!("Error: {}", format!("{}", err).trim_right()); - std::process::exit(1); - } - Ok(()) => {} + + if let Err(err) = result { + // The whitespace is being removed from the right because + // clap errors add a newline to the end of the output already + eprintln!("Error: {}", format!("{}", err).trim_right()); + std::process::exit(1); } }