Skip to content

Commit

Permalink
Fix clippy warnings (#2163)
Browse files Browse the repository at this point in the history
  • Loading branch information
fintelia committed Mar 9, 2024
1 parent 515b7e8 commit affd32a
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/codecs/avif/encoder.rs
Expand Up @@ -221,7 +221,7 @@ impl<W: Write> AvifEncoder<W> {
}

Ok(RgbColor::Rgb8(Img::new(
rgb::AsPixels::as_pixels(data),
AsPixels::as_pixels(data),
width as usize,
height as usize,
)))
Expand All @@ -238,7 +238,7 @@ impl<W: Write> AvifEncoder<W> {
}

Ok(RgbColor::Rgba8(Img::new(
rgb::AsPixels::as_pixels(data),
AsPixels::as_pixels(data),
width as usize,
height as usize,
)))
Expand Down
4 changes: 2 additions & 2 deletions src/codecs/bmp/decoder.rs
Expand Up @@ -1407,7 +1407,7 @@ mod test {
fn read_rect() {
let f =
BufReader::new(std::fs::File::open("tests/images/bmp/images/Core_8_Bit.bmp").unwrap());
let mut decoder = super::BmpDecoder::new(f).unwrap();
let mut decoder = BmpDecoder::new(f).unwrap();

let mut buf: Vec<u8> = vec![0; 8 * 8 * 3];
decoder.read_rect(0, 0, 8, 8, &mut buf, 8 * 3).unwrap();
Expand Down Expand Up @@ -1436,7 +1436,7 @@ mod test {
0x4d, 0x00, 0x2a, 0x00,
];

let decoder = BmpDecoder::new(std::io::Cursor::new(&data)).unwrap();
let decoder = BmpDecoder::new(Cursor::new(&data)).unwrap();
let mut buf = vec![0; usize::try_from(decoder.total_bytes()).unwrap()];
assert!(decoder.read_image(&mut buf).is_ok());
}
Expand Down
2 changes: 1 addition & 1 deletion src/codecs/gif.rs
Expand Up @@ -588,7 +588,7 @@ impl<W: Write> GifEncoder<W> {
gif_encoder = self.gif_encoder.as_mut().unwrap()
}

frame.dispose = gif::DisposalMethod::Background;
frame.dispose = DisposalMethod::Background;

gif_encoder
.write_frame(&frame)
Expand Down
4 changes: 2 additions & 2 deletions src/codecs/hdr/decoder.rs
Expand Up @@ -686,7 +686,7 @@ fn split_at_first<'a>(s: &'a str, separator: &str) -> Option<(&'a str, &'a str)>
// Reads input until b"\n" or EOF
// Returns vector of read bytes NOT including end of line characters
// or return None to indicate end of file
fn read_line_u8<R: Read>(r: &mut R) -> ::std::io::Result<Option<Vec<u8>>> {
fn read_line_u8<R: Read>(r: &mut R) -> io::Result<Option<Vec<u8>>> {
let mut ret = Vec::with_capacity(16);
loop {
let mut byte = [0];
Expand Down Expand Up @@ -734,7 +734,7 @@ mod tests {
#[test]
fn read_line_u8_test() {
let buf: Vec<_> = (&b"One\nTwo\nThree\nFour\n\n\n"[..]).into();
let input = &mut ::std::io::Cursor::new(buf);
let input = &mut Cursor::new(buf);
assert_eq!(&read_line_u8(input).unwrap().unwrap()[..], &b"One"[..]);
assert_eq!(&read_line_u8(input).unwrap().unwrap()[..], &b"Two"[..]);
assert_eq!(&read_line_u8(input).unwrap().unwrap()[..], &b"Three"[..]);
Expand Down
2 changes: 1 addition & 1 deletion src/codecs/hdr/encoder.rs
Expand Up @@ -421,7 +421,7 @@ fn noruncombine_test() {
assert_eq!(rsi.next(), Some(Norun(129, 7)));
assert_eq!(rsi.next(), None);

let v: Vec<_> = ::std::iter::repeat(())
let v: Vec<_> = std::iter::repeat(())
.flat_map(|_| (0..2))
.take(257)
.collect();
Expand Down
8 changes: 4 additions & 4 deletions src/codecs/openexr.rs
Expand Up @@ -228,7 +228,7 @@ fn write_buffer(

match color_type {
ExtendedColorType::Rgb32F => {
exr::prelude::Image // TODO compression method zip??
Image // TODO compression method zip??
::from_channels(
(width, height),
SpecificChannels::rgb(|pixel: Vec2<usize>| {
Expand All @@ -249,7 +249,7 @@ fn write_buffer(
}

ExtendedColorType::Rgba32F => {
exr::prelude::Image // TODO compression method zip??
Image // TODO compression method zip??
::from_channels(
(width, height),
SpecificChannels::rgba(|pixel: Vec2<usize>| {
Expand Down Expand Up @@ -374,12 +374,12 @@ mod test {

/// Read the file from the specified path into an `Rgba32FImage`.
fn read_as_rgba_image_from_file(path: impl AsRef<Path>) -> ImageResult<Rgba32FImage> {
read_as_rgba_image(BufReader::new(std::fs::File::open(path)?))
read_as_rgba_image(BufReader::new(File::open(path)?))
}

/// Read the file from the specified path into an `Rgb32FImage`.
fn read_as_rgb_image_from_file(path: impl AsRef<Path>) -> ImageResult<Rgb32FImage> {
read_as_rgb_image(BufReader::new(std::fs::File::open(path)?))
read_as_rgb_image(BufReader::new(File::open(path)?))
}

/// Read the file from the specified path into an `Rgb32FImage`.
Expand Down
2 changes: 1 addition & 1 deletion src/dynimage.rs
Expand Up @@ -1231,7 +1231,7 @@ mod test {
fn open_16bpc_png() {
let im_path = "./tests/images/png/16bpc/basn6a16.png";
let image = super::open(im_path).unwrap();
assert_eq!(image.color(), super::color::ColorType::Rgba16);
assert_eq!(image.color(), ColorType::Rgba16);
}

fn test_grayscale(mut img: super::DynamicImage, alpha_discarded: bool) {
Expand Down
12 changes: 6 additions & 6 deletions src/math/utils.rs
Expand Up @@ -48,7 +48,7 @@ mod test {
// We could check that case separately but it does not conform to the same expectation.
if new_w as u64 * 400u64 >= old_w as u64 * u64::from(u32::MAX) { return true; }

let result = super::resize_dimensions(old_w, 400, new_w, ::std::u32::MAX, false);
let result = super::resize_dimensions(old_w, 400, new_w, std::u32::MAX, false);
let exact = (400_f64 * new_w as f64 / old_w as f64).round() as u32;
result.0 == new_w && result.1 == exact.max(1)
}
Expand All @@ -61,7 +61,7 @@ mod test {
// We could check that case separately but it does not conform to the same expectation.
if 400u64 * new_h as u64 >= old_h as u64 * u64::from(u32::MAX) { return true; }

let result = super::resize_dimensions(400, old_h, ::std::u32::MAX, new_h, false);
let result = super::resize_dimensions(400, old_h, std::u32::MAX, new_h, false);
let exact = (400_f64 * new_h as f64 / old_h as f64).round() as u32;
result.1 == new_h && result.0 == exact.max(1)
}
Expand All @@ -87,12 +87,12 @@ mod test {

#[test]
fn resize_handles_overflow() {
let result = super::resize_dimensions(100, ::std::u32::MAX, 200, ::std::u32::MAX, true);
let result = super::resize_dimensions(100, std::u32::MAX, 200, std::u32::MAX, true);
assert!(result.0 == 100);
assert!(result.1 == ::std::u32::MAX);
assert!(result.1 == std::u32::MAX);

let result = super::resize_dimensions(::std::u32::MAX, 100, ::std::u32::MAX, 200, true);
assert!(result.0 == ::std::u32::MAX);
let result = super::resize_dimensions(std::u32::MAX, 100, std::u32::MAX, 200, true);
assert!(result.0 == std::u32::MAX);
assert!(result.1 == 100);
}

Expand Down
2 changes: 1 addition & 1 deletion src/traits.rs
Expand Up @@ -171,7 +171,7 @@ impl Lerp for f32 {

/// The pixel with an associated `ColorType`.
/// Not all possible pixels represent one of the predefined `ColorType`s.
pub trait PixelWithColorType: Pixel + self::private::SealedPixelWithColorType {
pub trait PixelWithColorType: Pixel + private::SealedPixelWithColorType {
/// This pixel has the format of one of the predefined `ColorType`s,
/// such as `Rgb8`, `La16` or `Rgba32F`.
/// This is needed for automatically detecting
Expand Down

0 comments on commit affd32a

Please sign in to comment.