diff --git a/crates/effects/src/stylize.rs b/crates/effects/src/stylize.rs index c7b3cff2..1de19312 100644 --- a/crates/effects/src/stylize.rs +++ b/crates/effects/src/stylize.rs @@ -131,7 +131,7 @@ pub fn scribble(path: &PathData, b: Rect, p: &Value) -> PathData { } } xs.sort_by(f64::total_cmp); - let mut spans: Vec<(f64, f64)> = xs.chunks_exact(2).map(|s| (s[0] - overlap, s[1] + overlap)).collect(); + let mut spans: Vec<(f64, f64)> = xs.as_chunks::<2>().0.iter().map(|s| (s[0] - overlap, s[1] + overlap)).collect(); if row % 2 == 1 { spans.reverse(); } diff --git a/crates/pathops/src/offset.rs b/crates/pathops/src/offset.rs index b7f87778..623ffbbb 100644 --- a/crates/pathops/src/offset.rs +++ b/crates/pathops/src/offset.rs @@ -160,7 +160,7 @@ fn deep_point(bp: &BezPath) -> Option { _ => {} }); xs.sort_by(f64::total_cmp); - for w in xs.chunks_exact(2) { + for w in xs.as_chunks::<2>().0 { let span = w[1] - w[0]; if best.is_none_or(|(b, _)| span > b) { best = Some((span, kurbo::Point::new((w[0] + w[1]) / 2.0, y))); diff --git a/crates/render/src/proof.rs b/crates/render/src/proof.rs index 840a7bcd..9a9a2515 100644 --- a/crates/render/src/proof.rs +++ b/crates/render/src/proof.rs @@ -247,7 +247,7 @@ pub(crate) fn post(pixels: &mut [u8], opts: &RenderOptions) { let lut = cms::active().proof_lut(proof); let mut last_in = [0u8; 4]; let mut last_out = [0u8; 4]; - for px in pixels.chunks_exact_mut(4) { + for px in pixels.as_chunks_mut::<4>().0 { let a = px[3]; if a == 0 { continue; diff --git a/crates/testkit/src/raster.rs b/crates/testkit/src/raster.rs index a639291f..1dbd9743 100644 --- a/crates/testkit/src/raster.rs +++ b/crates/testkit/src/raster.rs @@ -33,7 +33,7 @@ impl Image { } /// Number of pixels for which `pred(rgba)` holds. pub fn count(&self, pred: impl Fn([u8; 4]) -> bool) -> usize { - self.rgba.chunks_exact(4).filter(|p| pred([p[0], p[1], p[2], p[3]])).count() + self.rgba.as_chunks::<4>().0.iter().filter(|p| pred([p[0], p[1], p[2], p[3]])).count() } /// Pixels that differ from opaque white and are not fully transparent. pub fn ink(&self) -> usize { diff --git a/crates/text/src/layout.rs b/crates/text/src/layout.rs index facb80ec..0c83957f 100644 --- a/crates/text/src/layout.rs +++ b/crates/text/src/layout.rs @@ -158,7 +158,7 @@ fn poly_intervals(polys: &[Vec], y: f64) -> Vec<(f64, f64)> { } } xs.sort_by(f64::total_cmp); - xs.chunks_exact(2).map(|c| (c[0], c[1])).collect() + xs.as_chunks::<2>().0.iter().map(|c| (c[0], c[1])).collect() } /// Union of sorted-or-not intervals. diff --git a/crates/tools/src/builder.rs b/crates/tools/src/builder.rs index e78341b6..3a27c581 100644 --- a/crates/tools/src/builder.rs +++ b/crates/tools/src/builder.rs @@ -229,7 +229,7 @@ pub fn hatch(path: &BezPath, gap: f64) -> BezPath { } } xs.sort_by(f64::total_cmp); - for pair in xs.chunks_exact(2) { + for pair in xs.as_chunks::<2>().0 { out.move_to(unrot(Point::new(pair[0], y))); out.line_to(unrot(Point::new(pair[1], y))); } diff --git a/crates/trace/src/quantize.rs b/crates/trace/src/quantize.rs index 0b26de74..6b596cc8 100644 --- a/crates/trace/src/quantize.rs +++ b/crates/trace/src/quantize.rs @@ -19,7 +19,7 @@ fn luma(p: [u8; 4]) -> u8 { /// Reduce `img` to a palette according to `params.mode`. pub fn quantize(img: &Raster, params: &TraceParams) -> Quantized { - let px = img.rgba.chunks_exact(4).map(|c| [c[0], c[1], c[2], c[3]]); + let px = img.rgba.as_chunks::<4>().0.iter().map(|c| [c[0], c[1], c[2], c[3]]); match params.mode { Mode::BlackAndWhite => { let t = params.threshold; @@ -38,7 +38,7 @@ pub fn quantize(img: &Raster, params: &TraceParams) -> Quantized { } Mode::Grayscale => { let mut hist = [0u64; 256]; - for p in img.rgba.chunks_exact(4) { + for p in img.rgba.as_chunks::<4>().0 { if p[3] >= 128 { hist[luma([p[0], p[1], p[2], p[3]]) as usize] += 1; } @@ -58,7 +58,7 @@ pub fn quantize(img: &Raster, params: &TraceParams) -> Quantized { Mode::Color => { // 15-bit colour histogram with per-bin sums (exact bin means). let mut bins: Vec = vec![Bin::default(); 1 << 15]; - for p in img.rgba.chunks_exact(4) { + for p in img.rgba.as_chunks::<4>().0 { if p[3] >= 128 { let b = &mut bins[key(p[0], p[1], p[2])]; b.n += 1;