From 96fcc9c16af2c0de9e5158996bcac248a8f826da Mon Sep 17 00:00:00 2001 From: G2-Games Date: Mon, 26 Aug 2024 00:43:48 -0500 Subject: [PATCH] Fixed clippy complaints --- src/compression/dct.rs | 3 +++ src/lib.rs | 6 ++++-- src/operations.rs | 4 ++-- src/picture.rs | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/compression/dct.rs b/src/compression/dct.rs index 1072539..432a65e 100644 --- a/src/compression/dct.rs +++ b/src/compression/dct.rs @@ -100,6 +100,9 @@ pub fn idct(input: &[f32], width: usize, height: usize) -> Vec { /// /// Instead of using this, use the [`quantization_matrix`] function to /// get a quantization matrix corresponding to the image quality value. +/// +/// TODO: In the future, it would be cool to figure out how to generate a +/// quantization matrix of any size. const BASE_QUANTIZATION_MATRIX: [u16; 64] = [ 16, 11, 10, 16, 24, 40, 51, 61, 12, 12, 14, 19, 26, 58, 60, 55, diff --git a/src/lib.rs b/src/lib.rs index c071a55..c8ef9c2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -18,8 +18,10 @@ //! let width = 2; //! let height = 2; //! let bitmap = vec![ -//! 255, 255, 255, 255, 0, 255, 0, 128, -//! 255, 255, 255, 255, 0, 255, 0, 128 +//! 0xFF, 0xFF, 0xFF, 0xFF, +//! 0x00, 0x80, 0x00, 0x80, +//! 0xFF, 0xFF, 0xFF, 0xFF, +//! 0x00, 0x80, 0x00, 0x80, //! ]; //! //! // Create a 2×2 image in memory. Nothing is compressed or encoded diff --git a/src/operations.rs b/src/operations.rs index 38a2c56..385b0d8 100644 --- a/src/operations.rs +++ b/src/operations.rs @@ -58,9 +58,9 @@ pub fn add_rows(width: u32, height: u32, color_format: ColorFormat, data: &[u8]) // Interleave the offset alpha into the RGB bytes data[rgb_index..rgb_index + width as usize * (color_format.pbc() - 1)] .chunks(color_format.pbc() - 1) - .zip(data[alpha_index..alpha_index + width as usize].into_iter()) + .zip(data[alpha_index..alpha_index + width as usize].iter()) .flat_map(|(a, b)| { - a.into_iter().chain(vec![b]) + a.iter().chain(vec![b]) }) .copied() .collect() diff --git a/src/picture.rs b/src/picture.rs index e2b9bd1..737c8ca 100644 --- a/src/picture.rs +++ b/src/picture.rs @@ -264,5 +264,5 @@ fn decode_varint_stream(stream: &[u8]) -> Vec { pub fn open>(path: P) -> Result { let input = File::open(path)?; - Ok(SquishyPicture::decode(input)?) + SquishyPicture::decode(input) }