From 5827f4c0616f12debe0749d0d898c0212e9050b6 Mon Sep 17 00:00:00 2001 From: Andrew Thorburn Date: Thu, 21 May 2020 11:00:32 +0200 Subject: [PATCH] [Fix #45] Use sensible defaults instead of blindly unwrapping --- src/lib.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 081a6fc..da8026b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,3 @@ -#![feature(slice_patterns)] #![recursion_limit = "1024"] #[macro_use] extern crate error_chain; @@ -55,12 +54,11 @@ pub fn run() -> Result { _ => true, } }) - .unwrap(); + .unwrap_or(&""); let mut split_args = args.split(|x| x == command); - // Guaranteed two empty arrays, at minimum, so safe to unwrap - let global_args = split_args.next().unwrap(); - let command_args = split_args.next().unwrap(); + let global_args = split_args.next().unwrap_or(&[]); + let command_args = split_args.next().unwrap_or(&[]); let code = if TRIGGERS.contains(command) { match command_args { @@ -233,6 +231,7 @@ impl GitTogether { .get(&namespaced("aliases")) .unwrap_or_else(|_| String::new()) .split(',') + .filter(|s| s != &"") .any(|a| a == cmd) }