From 18f5d562f90e9213dd9de9e34233af08d0ca193f Mon Sep 17 00:00:00 2001 From: Kornel Date: Wed, 14 Aug 2024 00:01:53 +0100 Subject: [PATCH 1/2] Mark rayon as a public dependency --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 87184857f9..259bd81100 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -162,7 +162,7 @@ jobs: run: | echo "#![deny(exported_private_dependencies)]" | cat - src/lib.rs > src/lib.rs.0 mv src/lib.rs.0 src/lib.rs - echo 'cargo-features = ["public-dependency"]' | cat - Cargo.toml > Cargo.toml.0 + echo 'cargo-features = ["public-dependency"]' | cat - Cargo.toml | sed 's/rayon = { ver/rayon = { public = true, ver/' > Cargo.toml.0 mv Cargo.toml.0 Cargo.toml cargo check From 7a9937e4833f3b59dc752fd46a70db1cce6d837c Mon Sep 17 00:00:00 2001 From: Kornel Date: Wed, 14 Aug 2024 00:16:13 +0100 Subject: [PATCH 2/2] Clippy --- src/buffer.rs | 2 +- src/codecs/jpeg/encoder.rs | 4 ++-- src/codecs/openexr.rs | 2 +- src/codecs/pnm/decoder.rs | 4 ++-- src/flat.rs | 5 ++--- src/image.rs | 2 +- tests/reference_images.rs | 2 +- 7 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/buffer.rs b/src/buffer.rs index d1d779007e..6a87ae9313 100644 --- a/src/buffer.rs +++ b/src/buffer.rs @@ -1566,7 +1566,7 @@ mod test { let val = a.pixels_mut().next().unwrap(); *val = Rgb([42, 0, 0]); } - assert_eq!(a.data[0], 42) + assert_eq!(a.data[0], 42); } #[test] diff --git a/src/codecs/jpeg/encoder.rs b/src/codecs/jpeg/encoder.rs index 357fee4a1d..d641b44bb2 100644 --- a/src/codecs/jpeg/encoder.rs +++ b/src/codecs/jpeg/encoder.rs @@ -398,9 +398,9 @@ impl JpegEncoder { let mut tables = vec![STD_LUMA_QTABLE, STD_CHROMA_QTABLE]; tables.iter_mut().for_each(|t| { - t.iter_mut().for_each(|v| { + for v in t.iter_mut() { *v = clamp((u32::from(*v) * scale + 50) / 100, 1, u32::from(u8::MAX)) as u8; - }); + } }); JpegEncoder { diff --git a/src/codecs/openexr.rs b/src/codecs/openexr.rs index 3fee1e7f9a..40a9875b85 100644 --- a/src/codecs/openexr.rs +++ b/src/codecs/openexr.rs @@ -158,7 +158,7 @@ impl ImageDecoder for OpenExrDecoder { assert!( !has_invalid_size_or_overflowed, "byte buffer not large enough for the specified dimensions and f32 pixels" - ) + ); } let result = read() diff --git a/src/codecs/pnm/decoder.rs b/src/codecs/pnm/decoder.rs index 9697ab94c3..48f40bb20b 100644 --- a/src/codecs/pnm/decoder.rs +++ b/src/codecs/pnm/decoder.rs @@ -663,9 +663,9 @@ impl PnmDecoder { let factor = target_sample_max as f32 / current_sample_max as f32; if S::sample_size() == 1 { - buf.iter_mut().for_each(|v| { + for v in buf.iter_mut() { *v = (f32::from(*v) * factor).round() as u8; - }); + } } else if S::sample_size() == 2 { for chunk in buf.chunks_exact_mut(2) { let v = NativeEndian::read_u16(chunk); diff --git a/src/flat.rs b/src/flat.rs index 9883e94191..687d480368 100644 --- a/src/flat.rs +++ b/src/flat.rs @@ -322,9 +322,8 @@ impl SampleLayout { Some(size) => size, }; - match max_dim.checked_len() { - None => return true, - Some(_) => (), // Only want to know this didn't overflow. + if max_dim.checked_len().is_none() { + return true; }; // Each higher dimension must walk over all of one lower dimension. diff --git a/src/image.rs b/src/image.rs index 5bdecd4c9a..16c26f8a5d 100644 --- a/src/image.rs +++ b/src/image.rs @@ -1799,7 +1799,7 @@ mod tests { #[test] fn all() { - let all_formats: HashSet = HashSet::from_iter(ImageFormat::all()); + let all_formats: HashSet = ImageFormat::all().collect(); assert!(all_formats.contains(&ImageFormat::Avif)); assert!(all_formats.contains(&ImageFormat::Gif)); assert!(all_formats.contains(&ImageFormat::Bmp)); diff --git a/tests/reference_images.rs b/tests/reference_images.rs index da573b1ad2..26740670e1 100644 --- a/tests/reference_images.rs +++ b/tests/reference_images.rs @@ -359,7 +359,7 @@ fn check_hdr_references() { .rev() { if let Normal(name) = *c { - ref_path.push(name) + ref_path.push(name); } else { panic!() }