Skip to content

Commit 0608ab9

Browse files
committed
Fix some new nightly Clippy lints and run rustfmt with prettier config
1 parent 98fd4de commit 0608ab9

35 files changed

+191
-189
lines changed

benches/deflate.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
extern crate oxipng;
44
extern crate test;
55

6-
use oxipng::internal_tests::*;
7-
use oxipng::*;
86
use std::path::PathBuf;
7+
8+
use oxipng::{internal_tests::*, *};
99
use test::Bencher;
1010

1111
#[bench]

benches/filters.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
extern crate oxipng;
44
extern crate test;
55

6-
use oxipng::internal_tests::*;
7-
use oxipng::*;
86
use std::path::PathBuf;
7+
8+
use oxipng::{internal_tests::*, *};
99
use test::Bencher;
1010

1111
#[bench]

benches/interlacing.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
extern crate oxipng;
44
extern crate test;
55

6-
use oxipng::internal_tests::*;
7-
use oxipng::*;
86
use std::path::PathBuf;
7+
8+
use oxipng::{internal_tests::*, *};
99
use test::Bencher;
1010

1111
#[bench]

benches/reductions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
extern crate oxipng;
44
extern crate test;
55

6-
use oxipng::internal_tests::*;
7-
use oxipng::*;
86
use std::path::PathBuf;
7+
8+
use oxipng::{internal_tests::*, *};
99
use test::Bencher;
1010

1111
#[bench]

benches/strategies.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
extern crate oxipng;
44
extern crate test;
55

6-
use oxipng::internal_tests::*;
7-
use oxipng::*;
86
use std::path::PathBuf;
7+
8+
use oxipng::{internal_tests::*, *};
99
use test::Bencher;
1010

1111
#[bench]

benches/zopfli.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
extern crate oxipng;
44
extern crate test;
55

6-
use oxipng::internal_tests::*;
7-
use oxipng::*;
8-
use std::num::NonZeroU8;
9-
use std::path::PathBuf;
6+
use std::{num::NonZeroU8, path::PathBuf};
7+
8+
use oxipng::{internal_tests::*, *};
109
use test::Bencher;
1110

1211
// SAFETY: trivially safe. Stopgap solution until const unwrap is stabilized.

src/atomicmin.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
use std::sync::atomic::AtomicUsize;
2-
use std::sync::atomic::Ordering::SeqCst;
1+
use std::sync::atomic::{AtomicUsize, Ordering::SeqCst};
32

43
#[derive(Debug)]
54
pub struct AtomicMin {

src/colors.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
use rgb::{RGB16, RGBA8};
21
use std::{fmt, fmt::Display};
32

3+
use rgb::{RGB16, RGBA8};
4+
45
use crate::PngError;
56

67
#[derive(Debug, PartialEq, Eq, Clone)]

src/deflate/deflater.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use crate::atomicmin::AtomicMin;
2-
use crate::{PngError, PngResult};
31
use libdeflater::*;
42

3+
use crate::{atomicmin::AtomicMin, PngError, PngResult};
4+
55
pub fn deflate(data: &[u8], level: u8, max_size: &AtomicMin) -> PngResult<Vec<u8>> {
66
let mut compressor = Compressor::new(CompressionLvl::new(level.into()).unwrap());
77
let capacity = max_size

src/deflate/mod.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
mod deflater;
2-
use crate::AtomicMin;
3-
use crate::{PngError, PngResult};
4-
pub use deflater::crc32;
5-
pub use deflater::deflate;
6-
pub use deflater::inflate;
7-
use std::{fmt, fmt::Display};
8-
92
#[cfg(feature = "zopfli")]
103
use std::num::NonZeroU8;
4+
use std::{fmt, fmt::Display};
5+
6+
pub use deflater::{crc32, deflate, inflate};
7+
8+
use crate::{AtomicMin, PngError, PngResult};
119
#[cfg(feature = "zopfli")]
1210
mod zopfli_oxipng;
1311
#[cfg(feature = "zopfli")]

src/deflate/zopfli_oxipng.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
use crate::{PngError, PngResult};
21
use std::num::NonZeroU8;
32

3+
use crate::{PngError, PngResult};
4+
45
pub fn deflate(data: &[u8], iterations: NonZeroU8) -> PngResult<Vec<u8>> {
56
let mut output = Vec::with_capacity(data.len());
67
let options = zopfli::Options {

src/error.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
use std::{error::Error, fmt};
2+
13
use crate::colors::{BitDepth, ColorType};
2-
use std::error::Error;
3-
use std::fmt;
44

55
#[derive(Debug, Clone)]
66
#[non_exhaustive]

src/evaluate.rs

+9-11
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
//! Check if a reduction makes file smaller, and keep best reductions.
22
//! Works asynchronously when possible
33
4-
use crate::atomicmin::AtomicMin;
5-
use crate::deflate;
6-
use crate::filters::RowFilter;
7-
use crate::png::PngImage;
84
#[cfg(not(feature = "parallel"))]
9-
use crate::rayon;
10-
use crate::Deadline;
11-
use crate::PngError;
5+
use std::cell::RefCell;
6+
use std::sync::{
7+
atomic::{AtomicUsize, Ordering::*},
8+
Arc,
9+
};
10+
1211
#[cfg(feature = "parallel")]
1312
use crossbeam_channel::{unbounded, Receiver, Sender};
1413
use indexmap::IndexSet;
1514
use log::trace;
1615
use rayon::prelude::*;
16+
1717
#[cfg(not(feature = "parallel"))]
18-
use std::cell::RefCell;
19-
use std::sync::atomic::AtomicUsize;
20-
use std::sync::atomic::Ordering::*;
21-
use std::sync::Arc;
18+
use crate::rayon;
19+
use crate::{atomicmin::AtomicMin, deflate, filters::RowFilter, png::PngImage, Deadline, PngError};
2220

2321
pub struct Candidate {
2422
pub image: Arc<PngImage>,

src/filters.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
use std::mem::transmute;
2-
use std::{fmt, fmt::Display};
1+
use std::{fmt, fmt::Display, mem::transmute};
32

43
use crate::error::PngError;
54

src/headers.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
use crate::colors::{BitDepth, ColorType};
2-
use crate::deflate::{crc32, inflate};
3-
use crate::error::PngError;
4-
use crate::interlace::Interlacing;
5-
use crate::AtomicMin;
6-
use crate::Deflaters;
7-
use crate::PngResult;
81
use indexmap::IndexSet;
92
use log::warn;
103
use rgb::{RGB16, RGBA8};
114

5+
use crate::{
6+
colors::{BitDepth, ColorType},
7+
deflate::{crc32, inflate},
8+
error::PngError,
9+
interlace::Interlacing,
10+
AtomicMin, Deflaters, PngResult,
11+
};
12+
1213
#[derive(Debug, Clone)]
1314
/// Headers from the IHDR chunk of the image
1415
pub struct IhdrData {

src/interlace.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
use std::{fmt, fmt::Display};
22

3-
use crate::headers::IhdrData;
4-
use crate::png::PngImage;
5-
use crate::PngError;
63
use bitvec::prelude::*;
74

5+
use crate::{headers::IhdrData, png::PngImage, PngError};
6+
87
#[repr(u8)]
98
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
109
pub enum Interlacing {

src/lib.rs

+31-26
Original file line numberDiff line numberDiff line change
@@ -25,32 +25,40 @@ extern crate rayon;
2525
#[cfg(not(feature = "parallel"))]
2626
mod rayon;
2727

28-
use crate::atomicmin::AtomicMin;
29-
use crate::evaluate::Evaluator;
30-
use crate::headers::*;
31-
use crate::png::PngData;
32-
use crate::png::PngImage;
33-
use crate::reduction::*;
28+
use std::{
29+
borrow::Cow,
30+
fs::{File, Metadata},
31+
io::{stdin, stdout, BufWriter, Read, Write},
32+
path::Path,
33+
sync::{
34+
atomic::{AtomicBool, Ordering},
35+
Arc,
36+
},
37+
time::{Duration, Instant},
38+
};
39+
40+
pub use indexmap::{indexset, IndexSet};
3441
use log::{debug, info, trace, warn};
3542
use rayon::prelude::*;
36-
use std::borrow::Cow;
37-
use std::fs::{File, Metadata};
38-
use std::io::{stdin, stdout, BufWriter, Read, Write};
39-
use std::path::Path;
40-
use std::sync::atomic::{AtomicBool, Ordering};
41-
use std::sync::Arc;
42-
use std::time::{Duration, Instant};
43-
44-
pub use crate::colors::{BitDepth, ColorType};
45-
pub use crate::deflate::Deflaters;
46-
pub use crate::error::PngError;
47-
pub use crate::filters::RowFilter;
48-
pub use crate::headers::StripChunks;
49-
pub use crate::interlace::Interlacing;
50-
pub use crate::options::{InFile, Options, OutFile};
51-
pub use indexmap::{indexset, IndexSet};
5243
pub use rgb::{RGB16, RGBA8};
5344

45+
use crate::{
46+
atomicmin::AtomicMin,
47+
evaluate::Evaluator,
48+
headers::*,
49+
png::{PngData, PngImage},
50+
reduction::*,
51+
};
52+
pub use crate::{
53+
colors::{BitDepth, ColorType},
54+
deflate::Deflaters,
55+
error::PngError,
56+
filters::RowFilter,
57+
headers::StripChunks,
58+
interlace::Interlacing,
59+
options::{InFile, Options, OutFile},
60+
};
61+
5462
mod atomicmin;
5563
mod colors;
5664
mod deflate;
@@ -68,12 +76,9 @@ mod sanity_checks;
6876
/// Private to oxipng; don't use outside tests and benches
6977
#[doc(hidden)]
7078
pub mod internal_tests {
71-
pub use crate::atomicmin::*;
72-
pub use crate::deflate::*;
73-
pub use crate::png::*;
74-
pub use crate::reduction::*;
7579
#[cfg(feature = "sanity-checks")]
7680
pub use crate::sanity_checks::*;
81+
pub use crate::{atomicmin::*, deflate::*, png::*, reduction::*};
7782
}
7883

7984
pub type PngResult<T> = Result<T, PngError>;

src/main.rs

+5-13
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,15 @@
1616
#[cfg(not(feature = "parallel"))]
1717
mod rayon;
1818

19+
#[cfg(feature = "zopfli")]
20+
use std::num::NonZeroU8;
21+
use std::{ffi::OsString, fs::DirBuilder, io::Write, path::PathBuf, process::exit, time::Duration};
22+
1923
use clap::{value_parser, Arg, ArgAction, ArgMatches, Command};
2024
use indexmap::IndexSet;
2125
use log::{error, warn, Level, LevelFilter};
22-
use oxipng::Deflaters;
23-
use oxipng::Options;
24-
use oxipng::RowFilter;
25-
use oxipng::StripChunks;
26-
use oxipng::{InFile, OutFile};
26+
use oxipng::{Deflaters, InFile, Options, OutFile, RowFilter, StripChunks};
2727
use rayon::prelude::*;
28-
use std::ffi::OsString;
29-
use std::fs::DirBuilder;
30-
use std::io::Write;
31-
#[cfg(feature = "zopfli")]
32-
use std::num::NonZeroU8;
33-
use std::path::PathBuf;
34-
use std::process::exit;
35-
use std::time::Duration;
3628

3729
fn main() {
3830
// Note: clap 'wrap_help' is enabled to automatically wrap lines according to terminal width.

src/options.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
use log::warn;
2-
use std::fmt;
3-
use std::path::{Path, PathBuf};
4-
use std::time::Duration;
5-
6-
use crate::deflate::Deflaters;
7-
use crate::filters::RowFilter;
8-
use crate::headers::StripChunks;
9-
use crate::interlace::Interlacing;
1+
use std::{
2+
fmt,
3+
path::{Path, PathBuf},
4+
time::Duration,
5+
};
6+
107
use indexmap::{indexset, IndexSet};
8+
use log::warn;
9+
10+
use crate::{deflate::Deflaters, filters::RowFilter, headers::StripChunks, interlace::Interlacing};
1111

1212
#[derive(Clone, Debug)]
1313
pub enum OutFile {

src/png/mod.rs

+17-12
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
1-
use crate::colors::{BitDepth, ColorType};
2-
use crate::deflate;
3-
use crate::error::PngError;
4-
use crate::filters::*;
5-
use crate::headers::*;
6-
use crate::interlace::{deinterlace_image, interlace_image, Interlacing};
7-
use crate::Options;
1+
use std::{
2+
fs::File,
3+
io::{BufReader, Read, Write},
4+
path::Path,
5+
sync::Arc,
6+
};
7+
88
use bitvec::bitarr;
99
use libdeflater::{CompressionLvl, Compressor};
1010
use log::warn;
1111
use rgb::ComponentSlice;
1212
use rustc_hash::FxHashMap;
13-
use std::fs::File;
14-
use std::io::{BufReader, Read, Write};
15-
use std::iter::Iterator;
16-
use std::path::Path;
17-
use std::sync::Arc;
13+
14+
use crate::{
15+
colors::{BitDepth, ColorType},
16+
deflate,
17+
error::PngError,
18+
filters::*,
19+
headers::*,
20+
interlace::{deinterlace_image, interlace_image, Interlacing},
21+
Options,
22+
};
1823

1924
pub(crate) mod scan_lines;
2025

src/png/scan_lines.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
use crate::interlace::Interlacing;
2-
use crate::png::PngImage;
1+
use crate::{interlace::Interlacing, png::PngImage};
32

43
/// An iterator over the scan lines of a PNG image
54
#[derive(Debug, Clone)]

0 commit comments

Comments
 (0)