From 3d9d5eab2bddf780eaf182ebd6825cf331234a2b Mon Sep 17 00:00:00 2001 From: Luracasmus <77991691+Luracasmus@users.noreply.github.com> Date: Sat, 22 Nov 2025 19:24:51 +0100 Subject: [PATCH] Apply `clippy::missing_const_for_fn` --- src/headers.rs | 4 ++-- src/interlace.rs | 2 +- src/lib.rs | 2 +- src/options.rs | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/headers.rs b/src/headers.rs index 504fc8ff..f57de8c7 100644 --- a/src/headers.rs +++ b/src/headers.rs @@ -35,12 +35,12 @@ impl IhdrData { /// Byte length of IDAT that is correct for this IHDR #[must_use] - pub fn raw_data_size(&self) -> usize { + pub const fn raw_data_size(&self) -> usize { let w = self.width as usize; let h = self.height as usize; let bpp = self.bpp(); - fn bitmap_size(bpp: usize, w: usize, h: usize) -> usize { + const fn bitmap_size(bpp: usize, w: usize, h: usize) -> usize { (w * bpp).div_ceil(8) * h } diff --git a/src/interlace.rs b/src/interlace.rs index 23f0dd27..e0704426 100644 --- a/src/interlace.rs +++ b/src/interlace.rs @@ -149,7 +149,7 @@ fn deinterlace_bytes(png: &PngImage) -> Vec { lines.concat() } -fn increment_pass(current_pass: &mut u8, ihdr: &IhdrData) -> bool { +const fn increment_pass(current_pass: &mut u8, ihdr: &IhdrData) -> bool { if *current_pass == 7 { return false; } diff --git a/src/lib.rs b/src/lib.rs index ee827cd7..c4e8219f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -659,7 +659,7 @@ fn recompress_frames( } /// Check if an image was already optimized prior to oxipng's operations -fn is_fully_optimized(original_size: usize, optimized_size: usize, opts: &Options) -> bool { +const fn is_fully_optimized(original_size: usize, optimized_size: usize, opts: &Options) -> bool { original_size <= optimized_size && !opts.force } diff --git a/src/options.rs b/src/options.rs index 6bce95fb..4e3e8d4f 100644 --- a/src/options.rs +++ b/src/options.rs @@ -32,7 +32,7 @@ impl OutFile { /// /// This is a convenience method for `OutFile::Path { path: Some(path), preserve_attrs: false }`. #[must_use] - pub fn from_path(path: PathBuf) -> Self { + pub const fn from_path(path: PathBuf) -> Self { Self::Path { path: Some(path), preserve_attrs: false, @@ -199,7 +199,7 @@ impl Options { self } - fn apply_preset_2(self) -> Self { + const fn apply_preset_2(self) -> Self { self }