From 17f5cc36caab8cc6ea9aa2689b70a074fac4707c Mon Sep 17 00:00:00 2001 From: Josh Holmer Date: Tue, 5 Jul 2022 10:05:06 -0400 Subject: [PATCH] Fix clippy lints --- src/colors.rs | 2 +- src/deflate/mod.rs | 2 +- src/headers.rs | 2 +- src/png/mod.rs | 2 +- src/reduction/color.rs | 4 ++-- src/reduction/mod.rs | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/colors.rs b/src/colors.rs index ae698dca..350f4424 100644 --- a/src/colors.rs +++ b/src/colors.rs @@ -1,6 +1,6 @@ use std::fmt; -#[derive(Debug, PartialEq, Clone, Copy)] +#[derive(Debug, PartialEq, Eq, Clone, Copy)] /// The color type used to represent this image pub enum ColorType { /// Grayscale, with one color channel diff --git a/src/deflate/mod.rs b/src/deflate/mod.rs index 69879901..7a8af8a6 100644 --- a/src/deflate/mod.rs +++ b/src/deflate/mod.rs @@ -62,7 +62,7 @@ pub fn zopfli_deflate(data: &[u8]) -> PngResult> { Ok(output) } -#[derive(Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq, Eq)] /// DEFLATE algorithms supported by oxipng pub enum Deflaters { /// Use the Zlib/Miniz DEFLATE implementation diff --git a/src/headers.rs b/src/headers.rs index 318d4cdb..590aa205 100644 --- a/src/headers.rs +++ b/src/headers.rs @@ -64,7 +64,7 @@ impl IhdrData { } } -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, PartialEq, Eq, Clone)] /// Options to use for performing operations on headers (such as stripping) pub enum Headers { /// None diff --git a/src/png/mod.rs b/src/png/mod.rs index eea89b14..b429bb9f 100644 --- a/src/png/mod.rs +++ b/src/png/mod.rs @@ -344,7 +344,7 @@ impl PngImage { filter_line(filter, bpp, line.data, last_line, &mut f_buf); let size = f_buf.iter().fold(0_u64, |acc, &x| { let signed = x as i8; - acc + i16::from(signed).abs() as u64 + acc + i16::from(signed).unsigned_abs() as u64 }); if size < best_size { best_size = size; diff --git a/src/reduction/color.rs b/src/reduction/color.rs index 11686fc6..078b01c7 100644 --- a/src/reduction/color.rs +++ b/src/reduction/color.rs @@ -53,7 +53,7 @@ pub fn reduce_rgba_to_grayscale_alpha(png: &PngImage) -> Option { let mut aux_headers = png.aux_headers.clone(); if let Some(sbit_header) = png.aux_headers.get(b"sBIT") { - if let Some(&s) = sbit_header.get(0) { + if let Some(&s) = sbit_header.first() { aux_headers.insert(*b"sBIT", vec![s]); } } @@ -247,7 +247,7 @@ pub fn reduce_rgb_to_grayscale(png: &PngImage) -> Option { let mut aux_headers = png.aux_headers.clone(); if let Some(sbit_header) = png.aux_headers.get(b"sBIT") { - if let Some(&byte) = sbit_header.get(0) { + if let Some(&byte) = sbit_header.first() { aux_headers.insert(*b"sBIT", vec![byte]); } } diff --git a/src/reduction/mod.rs b/src/reduction/mod.rs index 6b89b839..89aec38b 100644 --- a/src/reduction/mod.rs +++ b/src/reduction/mod.rs @@ -117,7 +117,7 @@ fn do_palette_reduction(png: &PngImage, palette_map: &[Option; 256]) -> Opti let mut aux_headers = png.aux_headers.clone(); if let Some(bkgd_header) = png.aux_headers.get(b"bKGD") { if let Some(Some(map_to)) = bkgd_header - .get(0) + .first() .and_then(|&idx| palette_map.get(idx as usize)) { aux_headers.insert(*b"bKGD", vec![*map_to]);