From d123cb1dda17892792a674b40116140f2e57478c Mon Sep 17 00:00:00 2001 From: Kevin Reid Date: Thu, 9 Jan 2025 10:42:54 -0800 Subject: [PATCH] Rust 1.84: Lint: Apply `clippy::map_with_unused_argument_over_ranges`. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I’m not entirely sure I agree with this as general style, but I like it in the specific cases here. --- Cargo.toml | 1 + all-is-cubes-gpu/src/in_wgpu/raytrace_to_texture.rs | 5 ++--- all-is-cubes-wasm/Cargo.toml | 1 + all-is-cubes/src/block/tests.rs | 7 ++++--- all-is-cubes/src/time.rs | 4 ++-- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 18b642bd4..fc1a5fd70 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -244,6 +244,7 @@ large_futures = "warn" large_stack_frames = "warn" manual_let_else = "warn" map_unwrap_or = "warn" +map_with_unused_argument_over_ranges = "warn" missing_fields_in_debug = "warn" module_name_repetitions = "warn" modulo_arithmetic = "warn" diff --git a/all-is-cubes-gpu/src/in_wgpu/raytrace_to_texture.rs b/all-is-cubes-gpu/src/in_wgpu/raytrace_to_texture.rs index 4bbad166a..563f94928 100644 --- a/all-is-cubes-gpu/src/in_wgpu/raytrace_to_texture.rs +++ b/all-is-cubes-gpu/src/in_wgpu/raytrace_to_texture.rs @@ -167,9 +167,8 @@ impl Inner { let render_viewport = self.render_viewport; #[allow(clippy::needless_collect, reason = "needed with rayon and not without")] - let this_frame_pixels: Vec = (0..self.rays_per_frame) - .map(|_i| self.pixel_picker.next().unwrap()) - .collect(); + let this_frame_pixels: Vec = + (&mut self.pixel_picker).take(self.rays_per_frame).collect(); self.dirty_pixels = self.dirty_pixels.saturating_sub(this_frame_pixels.len()); diff --git a/all-is-cubes-wasm/Cargo.toml b/all-is-cubes-wasm/Cargo.toml index d95b61d9d..f00be836e 100644 --- a/all-is-cubes-wasm/Cargo.toml +++ b/all-is-cubes-wasm/Cargo.toml @@ -168,6 +168,7 @@ large_futures = "warn" large_stack_frames = "warn" manual_let_else = "warn" map_unwrap_or = "warn" +map_with_unused_argument_over_ranges = "warn" missing_fields_in_debug = "warn" module_name_repetitions = "warn" modulo_arithmetic = "warn" diff --git a/all-is-cubes/src/block/tests.rs b/all-is-cubes/src/block/tests.rs index 8251dedf9..a025b4fb0 100644 --- a/all-is-cubes/src/block/tests.rs +++ b/all-is-cubes/src/block/tests.rs @@ -177,9 +177,10 @@ fn overflow_evaluate() { let too_many_modifiers: u32 = block::Budget::default().components; let mut block = AIR; - block - .modifiers_mut() - .extend((0..too_many_modifiers).map(|_| Modifier::Rotate(GridRotation::CLOCKWISE))); + block.modifiers_mut().extend(std::iter::repeat_n( + Modifier::Rotate(GridRotation::CLOCKWISE), + too_many_modifiers as usize, + )); assert_eq!( block.evaluate(), Err(EvalBlockError { diff --git a/all-is-cubes/src/time.rs b/all-is-cubes/src/time.rs index cbfcc9a8a..67fd9b669 100644 --- a/all-is-cubes/src/time.rs +++ b/all-is-cubes/src/time.rs @@ -271,8 +271,8 @@ mod tests { fn clock_phase_advance() { let mut clock = Clock::new(TickSchedule::per_second(3), 0); assert_eq!( - (0..10) - .map(|_| clock.advance(false).prev_phase()) + std::iter::repeat_with(|| clock.advance(false).prev_phase()) + .take(10) .collect::>(), vec![0, 1, 2, 0, 1, 2, 0, 1, 2, 0], );