Skip to content

Commit

Permalink
Update MSRV and fix clippy issues (#2133)
Browse files Browse the repository at this point in the history
  • Loading branch information
fintelia authored Feb 11, 2024
1 parent d828548 commit 5d73d50
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 45 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
16 changes: 4 additions & 12 deletions src/codecs/png.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,10 +551,12 @@ pub struct PngEncoder<W: Write> {
/// 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,
Expand All @@ -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
Expand All @@ -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,
}

Expand Down Expand Up @@ -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 {
Expand Down
7 changes: 0 additions & 7 deletions src/codecs/pnm/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,13 +421,6 @@ trait HeaderReader: BufRead {
Ok(string)
}

/// Read the next line
fn read_next_line(&mut self) -> ImageResult<String> {
let mut buffer = String::new();
self.read_line(&mut buffer)?;
Ok(buffer)
}

fn read_next_u32(&mut self) -> ImageResult<u32> {
let s = self.read_next_string()?;
s.parse::<u32>()
Expand Down
1 change: 1 addition & 0 deletions src/codecs/webp/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down
27 changes: 6 additions & 21 deletions src/codecs/webp/vp8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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,
Expand Down Expand Up @@ -2126,12 +2129,6 @@ impl LumaMode {
}
}

impl Default for LumaMode {
fn default() -> Self {
LumaMode::DC
}
}

impl ChromaMode {
fn from_i8(val: i8) -> Option<Self> {
Some(match val {
Expand All @@ -2144,12 +2141,6 @@ impl ChromaMode {
}
}

impl Default for ChromaMode {
fn default() -> Self {
ChromaMode::DC
}
}

impl IntraMode {
fn from_i8(val: i8) -> Option<Self> {
Some(match val {
Expand All @@ -2168,12 +2159,6 @@ impl IntraMode {
}
}

impl Default for IntraMode {
fn default() -> Self {
IntraMode::DC
}
}

fn init_top_macroblocks(width: usize) -> Vec<MacroBlock> {
let mb_width = (width + 15) / 16;

Expand Down

0 comments on commit 5d73d50

Please sign in to comment.