From c21f78328637d13cfd511a2ec174123914bdc218 Mon Sep 17 00:00:00 2001 From: Michael Gieson Date: Thu, 8 Oct 2026 12:57:16 -0400 Subject: [PATCH] Clippy: use as_chunks for constant-size chunks (Rust 1.98) Rust 1.98's clippy adds `chunks_exact_to_as_chunks`, which `-D warnings` turns into an error, so `cargo xtask ci` fails on main with the current stable toolchain. The EPS stencil-mask loop and the cursor rasterizer (and two cursor tests) now use `as_chunks`, which yields fixed-size arrays; like `chunks_exact`, it skips an incomplete last chunk, so nothing changes in behaviour. Co-Authored-By: Claude Opus 5.5 (1M context) --- crates/eps/src/import/data.rs | 2 +- crates/ui-egui/src/cursors.rs | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/crates/eps/src/import/data.rs b/crates/eps/src/import/data.rs index 4a8d56d0..677e134f 100644 --- a/crates/eps/src/import/data.rs +++ b/crates/eps/src/import/data.rs @@ -743,7 +743,7 @@ impl Interp<'_> { let Some(mut img) = self.decode_image(image)? else { return Ok(None) }; let Some(m) = self.decode_image(stencil)? else { return Ok(Some(img)) }; let (w, h, mw, mh) = (img.w as usize, img.h as usize, m.w as usize, m.h as usize); - for (i, px) in img.rgba.chunks_exact_mut(4).enumerate() { + for (i, px) in img.rgba.as_chunks_mut::<4>().0.iter_mut().enumerate() { let (x, y) = (i % w, i / w); // The mask's pixel over this one (in 64 bits: rows times rows overflow 32). let at = (y as u64 * mh as u64 / h.max(1) as u64) * mw as u64 + x as u64 * mw as u64 / w.max(1) as u64; diff --git a/crates/ui-egui/src/cursors.rs b/crates/ui-egui/src/cursors.rs index e5c2e4aa..333c22ff 100644 --- a/crates/ui-egui/src/cursors.rs +++ b/crates/ui-egui/src/cursors.rs @@ -348,8 +348,7 @@ fn rasterize(c: Cursor, ppp: f32) -> Option { let (w, h) = (size.x as usize, size.y as usize); let mut px = vec![[0.0; 4]; w * h]; let corner = |v: &Vertex| (v.pos.to_vec2() * ppp - min, v.color); - for tri in mesh.indices.chunks_exact(3) { - let &[i, j, k] = tri else { continue }; + for &[i, j, k] in mesh.indices.as_chunks::<3>().0 { if let (Some(a), Some(b), Some(c)) = (mesh.vertices.get(i as usize), mesh.vertices.get(j as usize), mesh.vertices.get(k as usize)) { fill_triangle(&mut px, w, [corner(a), corner(b), corner(c)]); } @@ -463,7 +462,7 @@ mod tests { assert_eq!(img.rgba.len(), w * h * 4, "{c:?}"); assert!(img.hotspot[0] < img.size[0] && img.hotspot[1] < img.size[1], "{c:?} at {ppp}: {img:?}"); assert!(w as f32 <= 50.0 * ppp && h as f32 <= 50.0 * ppp, "{c:?} at {ppp}: {img:?}"); - assert!(img.rgba.chunks_exact(4).any(|p| p[3] == 255), "{c:?}: nothing opaque"); + assert!(img.rgba.as_chunks::<4>().0.iter().any(|p| p[3] == 255), "{c:?}: nothing opaque"); } } for c in [Cursor::Hand, Cursor::HandGrab, Cursor::ZoomIn, Cursor::ZoomOut, Cursor::NotAllowed] { @@ -482,7 +481,7 @@ mod tests { assert!(pixel(&img, hx, hy)[3] > 0, "{:?}", pixel(&img, hx, hy)); let body = pixel(&img, hx + 2, hy + 8); assert!(body[3] == 255 && body[..3].iter().all(|&c| c < 40), "{body:?}"); - assert!(img.rgba.chunks_exact(4).any(|p| p[3] == 255 && p[..3].iter().all(|&c| c > 215)), "no white halo"); + assert!(img.rgba.as_chunks::<4>().0.iter().any(|p| p[3] == 255 && p[..3].iter().all(|&c| c > 215)), "no white halo"); // Nothing left of or above the tip but the halo. assert!((0..img.size[1] as usize).all(|y| pixel(&img, 0, y)[..3].iter().all(|&c| c > 100) || pixel(&img, 0, y)[3] < 128)); // At twice the pixels per point, twice the pixels.