Skip to content

Commit 39a6400

Browse files
fix(ops): resolve strict clippy warnings
1 parent 30c1f1c commit 39a6400

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎crates/pixl-ops/src/lib.rs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ pub fn resize(
8282
validate_dimensions(width, height, PixelFormat::Rgba8, limits).map_err(Error::Limit)?;
8383
let mut src = images::Image::new(image.width(), image.height(), PixelType::U8x4);
8484
src.buffer_mut().copy_from_slice(image.as_bytes());
85-
for pixel in src.buffer_mut().chunks_exact_mut(4) {
85+
for pixel in src.buffer_mut().as_chunks_mut::<4>().0 {
8686
let alpha = u16::from(pixel[3]);
8787
for channel in &mut pixel[..3] {
8888
*channel = ((u16::from(*channel) * alpha + 127) / 255) as u8;
@@ -99,14 +99,14 @@ pub fn resize(
9999
.try_reserve_exact(dst.buffer().len())
100100
.map_err(|_| Error::Limit(pixl_core::Error::AllocationFailed))?;
101101
pixels.extend_from_slice(dst.buffer());
102-
for pixel in pixels.chunks_exact_mut(4) {
102+
for pixel in pixels.as_chunks_mut::<4>().0 {
103103
let alpha = u16::from(pixel[3]);
104104
if alpha == 0 {
105105
pixel[..3].fill(0);
106106
} else {
107107
for channel in &mut pixel[..3] {
108-
*channel =
109-
((u16::from(*channel) * 255 + alpha / 2) / alpha).min(255) as u8;
108+
let value = u16::from(*channel) * 255 + alpha / 2;
109+
*channel = value.checked_div(alpha).unwrap_or(0).min(255) as u8;
110110
}
111111
}
112112
}

0 commit comments

Comments
 (0)