From fe64cbcd3a3f4a83d8e5ad54326b709abc9193c1 Mon Sep 17 00:00:00 2001 From: greg Date: Tue, 1 May 2018 18:10:24 -0700 Subject: [PATCH] Refactor --- schala-repl/src/lib.rs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/schala-repl/src/lib.rs b/schala-repl/src/lib.rs index 7cfb8b4..fb1ba3b 100644 --- a/schala-repl/src/lib.rs +++ b/schala-repl/src/lib.rs @@ -298,19 +298,16 @@ impl Repl { Some(s) => s.to_string(), None => return Some(format!("Must specify a stage to debug")), }; - let maybe_debug = stages.iter().find(|stage_name| **stage_name == debug_stage); - match (show, maybe_debug) { - (true, Some(s)) => { - let msg = format!("Enabling debug for stage {}", debug_stage); + if let Some(stage) = stages.iter().find(|stage_name| **stage_name == debug_stage) { + let msg = format!("{} debug for stage {}", if show { "Enabling" } else { "Disabling" }, debug_stage); + if show { self.options.debug_stages.insert(debug_stage); - Some(msg) - }, - (false, Some(s)) => { - let msg = format!("Disabling debug for stage {}", debug_stage); + } else { self.options.debug_stages.remove(&debug_stage); - Some(msg) - }, - (_, None) => Some(format!("couldn't find it")) + } + Some(msg) + } else { + Some(format!("Couldn't find stage: {}", debug_stage)) } }, _ => Some(format!("Unknown debug command"))