From af6ed4d64dd8d37563f33a8b919f51232d044fa7 Mon Sep 17 00:00:00 2001 From: Marcel Kummer Date: Mon, 13 Nov 2023 20:20:05 +0100 Subject: [PATCH] Use std::Vec::retain instead of awkward do-while loop --- src/effects/pixelflow.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/effects/pixelflow.rs b/src/effects/pixelflow.rs index 986f307..9f92eaf 100644 --- a/src/effects/pixelflow.rs +++ b/src/effects/pixelflow.rs @@ -35,9 +35,11 @@ impl PixelFlow { } fn remove_pulses(&mut self) { - // TODO Try self.pulses.retain(|pulse| pulse.position < self.pixel_count as f32 - 1.0); // FIXME This is not flow direction agnostic! - // This would be nicer as a do-while loop. And feels awkward in any case. + self.pulses + .retain(|pulse| pulse.position < self.pixel_count as f32 - 1.0); + return; + let mut check_again = true; while check_again { check_again = false;