Fixed clippy complaints

This commit is contained in:
G2-Games 2024-08-26 00:43:48 -05:00
parent 3ce09575dc
commit 96fcc9c16a
4 changed files with 10 additions and 5 deletions

View file

@ -100,6 +100,9 @@ pub fn idct(input: &[f32], width: usize, height: usize) -> Vec<u8> {
///
/// 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,

View file

@ -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

View file

@ -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()

View file

@ -264,5 +264,5 @@ fn decode_varint_stream(stream: &[u8]) -> Vec<i16> {
pub fn open<P: AsRef<Path>>(path: P) -> Result<SquishyPicture, Error> {
let input = File::open(path)?;
Ok(SquishyPicture::decode(input)?)
SquishyPicture::decode(input)
}