Fix Clippy lints

This commit is contained in:
Alejandro González 2023-04-15 16:21:22 +02:00
parent 9358f1b55f
commit b3d5fae116
No known key found for this signature in database
5 changed files with 18 additions and 10 deletions

View file

@ -22,6 +22,10 @@ name = "oxipng"
path = "src/main.rs" path = "src/main.rs"
required-features = ["binary"] required-features = ["binary"]
[[bench]]
name = "zopfli"
required-features = ["zopfli"]
[dependencies] [dependencies]
zopfli = { version = "0.7.1", optional = true } zopfli = { version = "0.7.1", optional = true }
rgb = "0.8.33" rgb = "0.8.33"

View file

@ -31,11 +31,11 @@ use crate::evaluate::Evaluator;
use crate::png::PngData; use crate::png::PngData;
use crate::png::PngImage; use crate::png::PngImage;
use crate::reduction::*; use crate::reduction::*;
use log::{debug, error, info, warn}; use log::{debug, info, warn};
use rayon::prelude::*; use rayon::prelude::*;
use std::fmt; use std::fmt;
use std::fs::{copy, File, Metadata}; use std::fs::{copy, File, Metadata};
use std::io::{stdin, stdout, BufWriter, Cursor, Read, Write}; use std::io::{stdin, stdout, BufWriter, Read, Write};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc; use std::sync::Arc;
@ -1048,6 +1048,8 @@ fn copy_times(input_path_meta: &Metadata, out_path: &Path) -> PngResult<()> {
mod sanity_checks { mod sanity_checks {
use super::*; use super::*;
use image::{DynamicImage, GenericImageView, ImageFormat, Pixel}; use image::{DynamicImage, GenericImageView, ImageFormat, Pixel};
use log::error;
use std::io::Cursor;
/// Validate that the output png data still matches the original image /// Validate that the output png data still matches the original image
pub(super) fn validate_output(output: &[u8], original_data: &[u8]) -> bool { pub(super) fn validate_output(output: &[u8], original_data: &[u8]) -> bool {

View file

@ -52,6 +52,7 @@ where
impl<I: Iterator> ParallelIterator for I {} impl<I: Iterator> ParallelIterator for I {}
#[allow(dead_code)]
pub fn join<A, B>(a: impl FnOnce() -> A, b: impl FnOnce() -> B) -> (A, B) { pub fn join<A, B>(a: impl FnOnce() -> A, b: impl FnOnce() -> B) -> (A, B) {
(a(), b()) (a(), b())
} }

View file

@ -27,6 +27,7 @@ fn get_opts(input: &Path) -> (OutFile, oxipng::Options) {
} }
/// Add callback to allow checks before the output file is deleted again /// Add callback to allow checks before the output file is deleted again
#[allow(clippy::too_many_arguments)]
fn test_it_converts_callbacks<CBPRE, CBPOST>( fn test_it_converts_callbacks<CBPRE, CBPOST>(
input: PathBuf, input: PathBuf,
output: &OutFile, output: &OutFile,
@ -38,8 +39,8 @@ fn test_it_converts_callbacks<CBPRE, CBPOST>(
mut callback_pre: CBPRE, mut callback_pre: CBPRE,
mut callback_post: CBPOST, mut callback_post: CBPOST,
) where ) where
CBPOST: FnMut(&Path) -> (), CBPOST: FnMut(&Path),
CBPRE: FnMut(&Path) -> (), CBPRE: FnMut(&Path),
{ {
let png = PngData::new(&input, opts.fix_errors).unwrap(); let png = PngData::new(&input, opts.fix_errors).unwrap();
@ -48,14 +49,14 @@ fn test_it_converts_callbacks<CBPRE, CBPOST>(
callback_pre(&input); callback_pre(&input);
match oxipng::optimize(&InFile::Path(input), &output, &opts) { match oxipng::optimize(&InFile::Path(input), output, opts) {
Ok(_) => (), Ok(_) => (),
Err(x) => panic!("{}", x), Err(x) => panic!("{}", x),
}; };
let output = output.path().unwrap(); let output = output.path().unwrap();
assert!(output.exists()); assert!(output.exists());
callback_post(&output); callback_post(output);
let png = match PngData::new(output, opts.fix_errors) { let png = match PngData::new(output, opts.fix_errors) {
Ok(x) => x, Ok(x) => x,

View file

@ -834,7 +834,7 @@ fn small_files() {
let png = match PngData::new(output, opts.fix_errors) { let png = match PngData::new(output, opts.fix_errors) {
Ok(x) => x, Ok(x) => x,
Err(x) => { Err(x) => {
remove_file(&output).ok(); remove_file(output).ok();
panic!("{}", x) panic!("{}", x)
} }
}; };
@ -866,7 +866,7 @@ fn palette_should_be_reduced_with_dupes() {
let png = match PngData::new(output, opts.fix_errors) { let png = match PngData::new(output, opts.fix_errors) {
Ok(x) => x, Ok(x) => x,
Err(x) => { Err(x) => {
remove_file(&output).ok(); remove_file(output).ok();
panic!("{}", x) panic!("{}", x)
} }
}; };
@ -899,7 +899,7 @@ fn palette_should_be_reduced_with_unused() {
let png = match PngData::new(output, opts.fix_errors) { let png = match PngData::new(output, opts.fix_errors) {
Ok(x) => x, Ok(x) => x,
Err(x) => { Err(x) => {
remove_file(&output).ok(); remove_file(output).ok();
panic!("{}", x) panic!("{}", x)
} }
}; };
@ -932,7 +932,7 @@ fn palette_should_be_reduced_with_both() {
let png = match PngData::new(output, opts.fix_errors) { let png = match PngData::new(output, opts.fix_errors) {
Ok(x) => x, Ok(x) => x,
Err(x) => { Err(x) => {
remove_file(&output).ok(); remove_file(output).ok();
panic!("{}", x) panic!("{}", x)
} }
}; };