From 54c9ec73c3ce28496a6e461ebda49818d097cdd0 Mon Sep 17 00:00:00 2001 From: Michael Murphy <mmstickman@gmail.com> Date: Sun, 22 Jul 2018 10:34:40 -0600 Subject: [PATCH] Simplify array filter assignment --- src/lib/shell/assignments.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/lib/shell/assignments.rs b/src/lib/shell/assignments.rs index 57e1e34c..cf4de527 100644 --- a/src/lib/shell/assignments.rs +++ b/src/lib/shell/assignments.rs @@ -218,11 +218,10 @@ impl VariableStore for Shell { Ok(VariableType::Array(values)) => { match self.variables.get_mut(key.name) { Some(VariableType::Array(ref mut array)) => { - let mut iterator: Box<Iterator<Item=&types::Str>> = Box::new(array.iter()); - for value in &values { - iterator = Box::new(iterator.filter(move |item| *item != value)); - } - *array = iterator.cloned().collect(); + *array = array.iter() + .filter(|item| values.iter().all(|value| *item != value)) + .cloned() + .collect(); } None => { eprintln!("ion: assignment error: {}: cannot head concatenate non-array variable", key.name); -- GitLab