From 6b7c8c2f32b535ff756d3c13677f5953817bcc7f Mon Sep 17 00:00:00 2001
From: Michael Gattozzi <mgattozzi@gmail.com>
Date: Wed, 14 Oct 2015 11:04:33 -0400
Subject: [PATCH] Changed if else in run function

Cleaned up the syntax by using a match statement. Made it easier
to read and understand what was going on
On branch master
Changes to be committed:
	modified:   command.rs
---
 src/command.rs | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/src/command.rs b/src/command.rs
index 871cdb34..4c3822aa 100644
--- a/src/command.rs
+++ b/src/command.rs
@@ -7,15 +7,12 @@ pub struct InstructionOut {
 
 pub fn run(input_command: Vec<&str>) -> Option<InstructionOut> {
     let args = input_command.as_slice();
-    let length = args.len();
     let output: Option<Output>;
-    if length ==0 {
-        output = Command::new("").output().ok();
-    } else if length ==  1 {
-        output = Command::new(&args[0]).output().ok();
-    } else {
-        output = Command::new(&args[0]).args(&args[1..]).output().ok();
-    };
+    match args.len() {
+        0 => output = Command::new("").output().ok(),
+        1 => output = Command::new(&args[0]).output().ok(),
+        _ => output = Command::new(&args[0]).args(&args[1..]).output().ok(),
+    }
     if output.is_some() {
         let output = output.unwrap();
         Some(InstructionOut {
-- 
GitLab