Fix more clippy lints in the emulator

This commit is contained in:
Gwilym Inzani 2024-04-09 20:56:19 +01:00
parent 08ad8765de
commit 65388e01f5

View file

@ -1,20 +1,15 @@
use std::path::Path; use std::path::Path;
use image::{io::Reader, DynamicImage}; use image::io::Reader;
pub struct ComparisonResult { pub struct ComparisonResult {
matches: bool, matches: bool,
image: DynamicImage,
} }
impl ComparisonResult { impl ComparisonResult {
pub fn success(&self) -> bool { pub fn success(&self) -> bool {
self.matches self.matches
} }
pub fn image(&self) -> &DynamicImage {
&self.image
}
} }
const WIDTH: usize = 240; const WIDTH: usize = 240;
@ -36,10 +31,7 @@ pub fn compare_image(
let (exp_dim_x, exp_dim_y) = expected_buffer.dimensions(); let (exp_dim_x, exp_dim_y) = expected_buffer.dimensions();
if exp_dim_x != WIDTH as u32 || exp_dim_y != HEIGHT as u32 { if exp_dim_x != WIDTH as u32 || exp_dim_y != HEIGHT as u32 {
return Ok(ComparisonResult { return Ok(ComparisonResult { matches: false });
matches: false,
image: expected,
});
} }
for y in 0..HEIGHT { for y in 0..HEIGHT {
@ -49,16 +41,10 @@ pub fn compare_image(
let image_pixel = convert_rgba_to_nearest_gba_colour(image_pixel.0); let image_pixel = convert_rgba_to_nearest_gba_colour(image_pixel.0);
if image_pixel[0..3] != video_pixel.to_le_bytes()[0..3] { if image_pixel[0..3] != video_pixel.to_le_bytes()[0..3] {
return Ok(ComparisonResult { return Ok(ComparisonResult { matches: false });
matches: false,
image: expected,
});
} }
} }
} }
Ok(ComparisonResult { Ok(ComparisonResult { matches: true })
matches: true,
image: expected,
})
} }