From 83386d5bd9a8a4998ddd24a95dd9ac96f70bba69 Mon Sep 17 00:00:00 2001 From: Michael Sippel Date: Fri, 10 Sep 2021 11:10:05 +0200 Subject: [PATCH] SdfTerm: simplify get_order() --- sdf_editor/src/main.rs | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/sdf_editor/src/main.rs b/sdf_editor/src/main.rs index e773d58..de5e7f5 100644 --- a/sdf_editor/src/main.rs +++ b/sdf_editor/src/main.rs @@ -92,20 +92,18 @@ impl SdfTerm { pub fn get_order(&mut self) -> Vec { vec![ - self.bg_layers.iter().filter( - |(_pt, (active, _id))| *active - ) - .collect::>() - .into_iter(), - self.fg_layers.iter().filter( - |(_pt, (active, _id))| *active - ) - .collect::>() - .into_iter() + self.bg_layers.iter(), + self.fg_layers.iter() ] .into_iter() .flatten() - .map(|(_,(_,id))| (*id).into()) + .filter_map( + |(_pt,(active,id))| + if *active { + Some((*id).into()) + } else { + None + }) .collect::>() } @@ -274,8 +272,6 @@ async fn main() { Point2::new(0,0) .. Point2::new(new_size.x, new_size.y) ) ); - - } TerminalEvent::Input(Event::Key(Key::Ctrl('c'))) | TerminalEvent::Input(Event::Key(Key::Ctrl('g'))) |