From 5d73d50c53a8b4755e55b93949f02d91e011077f Mon Sep 17 00:00:00 2001 From: Jonathan Behrens Date: Sun, 11 Feb 2024 12:40:33 -0800 Subject: [PATCH] Update MSRV and fix clippy issues (#2133) --- .github/workflows/rust.yml | 8 ++++---- Cargo.toml | 2 +- src/codecs/png.rs | 16 ++++------------ src/codecs/pnm/decoder.rs | 7 ------- src/codecs/webp/encoder.rs | 1 + src/codecs/webp/vp8.rs | 27 ++++++--------------------- 6 files changed, 16 insertions(+), 45 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 679c40c68a..e9865f408e 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -38,14 +38,14 @@ jobs: strategy: fail-fast: false matrix: - rust: ["1.61.0", nightly, beta] + rust: ["1.63.0", nightly, beta] steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@nightly - if: ${{ matrix.rust == '1.61.0' }} + if: ${{ matrix.rust == '1.63.0' }} - name: Generate Cargo.lock with minimal-version dependencies - if: ${{ matrix.rust == '1.61.0' }} + if: ${{ matrix.rust == '1.63.0' }} run: cargo -Zminimal-versions generate-lockfile - uses: dtolnay/rust-toolchain@v1 @@ -58,7 +58,7 @@ jobs: - name: build run: cargo build -v --features webp,webp-encoder - name: test - if: ${{ matrix.rust != '1.61.0' }} + if: ${{ matrix.rust != '1.63.0' }} run: > cargo test -v --features webp,webp-encoder && cargo doc -v --features webp,webp-encoder diff --git a/Cargo.toml b/Cargo.toml index c7cfd08393..59bfee1d2c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" resolver = "2" # note: when changed, also update test runner in `.github/workflows/rust.yml` -rust-version = "1.61.0" +rust-version = "1.63.0" license = "MIT OR Apache-2.0" description = "Imaging library. Provides basic image processing and encoders/decoders for common image formats." diff --git a/src/codecs/png.rs b/src/codecs/png.rs index 39e1e5cb97..d2d0bf6898 100644 --- a/src/codecs/png.rs +++ b/src/codecs/png.rs @@ -551,10 +551,12 @@ pub struct PngEncoder { /// Compression level of a PNG encoder. The default setting is `Fast`. #[derive(Clone, Copy, Debug, Eq, PartialEq)] #[non_exhaustive] +#[derive(Default)] pub enum CompressionType { /// Default compression level Default, /// Fast, minimal compression + #[default] Fast, /// High compression level Best, @@ -571,6 +573,7 @@ pub enum CompressionType { /// The default filter is `Adaptive`. #[derive(Clone, Copy, Debug, Eq, PartialEq)] #[non_exhaustive] +#[derive(Default)] pub enum FilterType { /// No processing done, best used for low bit depth grayscale or data with a /// low color count @@ -585,6 +588,7 @@ pub enum FilterType { Paeth, /// Uses a heuristic to select one of the preceding filters for each /// scanline rather than one filter for the entire image + #[default] Adaptive, } @@ -769,18 +773,6 @@ impl ImageError { } } -impl Default for CompressionType { - fn default() -> Self { - CompressionType::Fast - } -} - -impl Default for FilterType { - fn default() -> Self { - FilterType::Adaptive - } -} - impl fmt::Display for BadPngRepresentation { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { diff --git a/src/codecs/pnm/decoder.rs b/src/codecs/pnm/decoder.rs index 03faf7c084..9105662269 100644 --- a/src/codecs/pnm/decoder.rs +++ b/src/codecs/pnm/decoder.rs @@ -421,13 +421,6 @@ trait HeaderReader: BufRead { Ok(string) } - /// Read the next line - fn read_next_line(&mut self) -> ImageResult { - let mut buffer = String::new(); - self.read_line(&mut buffer)?; - Ok(buffer) - } - fn read_next_u32(&mut self) -> ImageResult { let s = self.read_next_string()?; s.parse::() diff --git a/src/codecs/webp/encoder.rs b/src/codecs/webp/encoder.rs index 8fb125b65b..4f809f901e 100644 --- a/src/codecs/webp/encoder.rs +++ b/src/codecs/webp/encoder.rs @@ -32,6 +32,7 @@ pub struct WebPQuality(Quality); #[derive(Debug, Copy, Clone)] enum Quality { Lossless, + #[allow(unused)] #[deprecated = "Lossy encoding will be removed in a future version. See: https://github.com/image-rs/image/issues/1984"] Lossy(u8), } diff --git a/src/codecs/webp/vp8.rs b/src/codecs/webp/vp8.rs index f18b64aeb4..bebd1d1d49 100644 --- a/src/codecs/webp/vp8.rs +++ b/src/codecs/webp/vp8.rs @@ -50,9 +50,10 @@ const B_HU_PRED: i8 = 9; // Prediction mode enum #[repr(i8)] -#[derive(Clone, Copy, Debug, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)] enum LumaMode { /// Predict DC using row above and column to the left. + #[default] DC = DC_PRED, /// Predict rows using row above. @@ -69,9 +70,10 @@ enum LumaMode { } #[repr(i8)] -#[derive(Clone, Copy, Debug, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)] enum ChromaMode { /// Predict DC using row above and column to the left. + #[default] DC = DC_PRED, /// Predict rows using row above. @@ -85,8 +87,9 @@ enum ChromaMode { } #[repr(i8)] -#[derive(Clone, Copy, Debug, PartialEq, Eq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)] enum IntraMode { + #[default] DC = B_DC_PRED, TM = B_TM_PRED, VE = B_VE_PRED, @@ -2126,12 +2129,6 @@ impl LumaMode { } } -impl Default for LumaMode { - fn default() -> Self { - LumaMode::DC - } -} - impl ChromaMode { fn from_i8(val: i8) -> Option { Some(match val { @@ -2144,12 +2141,6 @@ impl ChromaMode { } } -impl Default for ChromaMode { - fn default() -> Self { - ChromaMode::DC - } -} - impl IntraMode { fn from_i8(val: i8) -> Option { Some(match val { @@ -2168,12 +2159,6 @@ impl IntraMode { } } -impl Default for IntraMode { - fn default() -> Self { - IntraMode::DC - } -} - fn init_top_macroblocks(width: usize) -> Vec { let mb_width = (width + 15) / 16;