diff --git a/agb-image-converter/src/bin/convert.rs b/agb-image-converter/src/bin/convert.rs index 0796b7b4..82737b86 100644 --- a/agb-image-converter/src/bin/convert.rs +++ b/agb-image-converter/src/bin/convert.rs @@ -2,7 +2,7 @@ use std::env; use agb_image_converter::{convert_image, ImageConverterConfig, TileSize}; -fn main() -> () { +fn main() { let args: Vec<_> = env::args().collect(); let file_path = &args[1]; @@ -12,6 +12,5 @@ fn main() -> () { tile_size: TileSize::Tile8, input_image: file_path.into(), output_file: output_path.into(), - output_name: "HELLO".to_owned(), }); } diff --git a/agb-image-converter/src/colour.rs b/agb-image-converter/src/colour.rs index f5440e6f..31151d87 100644 --- a/agb-image-converter/src/colour.rs +++ b/agb-image-converter/src/colour.rs @@ -10,7 +10,7 @@ impl Colour { Colour { r, g, b } } - pub fn to_rgb15(&self) -> u16 { + pub fn to_rgb15(self) -> u16 { let (r, g, b) = (self.r as u16, self.g as u16, self.b as u16); ((r >> 3) & 31) | (((g >> 3) & 31) << 5) | (((b >> 3) & 31) << 10) } diff --git a/agb-image-converter/src/lib.rs b/agb-image-converter/src/lib.rs index 399abb3c..2d8b3450 100644 --- a/agb-image-converter/src/lib.rs +++ b/agb-image-converter/src/lib.rs @@ -18,8 +18,8 @@ pub enum TileSize { } impl TileSize { - fn to_size(&self) -> usize { - match &self { + fn to_size(self) -> usize { + match self { TileSize::Tile8 => 8, TileSize::Tile16 => 16, } diff --git a/agb-image-converter/src/palette16.rs b/agb-image-converter/src/palette16.rs index d705164a..0c7e3451 100644 --- a/agb-image-converter/src/palette16.rs +++ b/agb-image-converter/src/palette16.rs @@ -107,7 +107,7 @@ impl Palette16Optimiser { .cloned() .collect::>(); - while unsatisfied_palettes.len() > 0 { + while !unsatisfied_palettes.is_empty() { let palette = self.find_maximal_palette_for(&unsatisfied_palettes, transparent_colour); for test_palette in unsatisfied_palettes.clone() { @@ -130,8 +130,8 @@ impl Palette16Optimiser { } Palette16OptimisationResults { - assignments, optimised_palettes, + assignments, } } diff --git a/agb-image-converter/src/rust_generator.rs b/agb-image-converter/src/rust_generator.rs index bac750c7..5824ca78 100644 --- a/agb-image-converter/src/rust_generator.rs +++ b/agb-image-converter/src/rust_generator.rs @@ -11,9 +11,9 @@ pub(crate) fn generate_code( image: &Image, tile_size: TileSize, ) -> io::Result<()> { - write!( + writeln!( output, - "pub const PALETTE_DATA: &'static [crate::display::palette16::Palette16] = &[\n", + "pub const PALETTE_DATA: &'static [crate::display::palette16::Palette16] = &[", )?; for palette in &results.optimised_palettes { @@ -27,12 +27,13 @@ pub(crate) fn generate_code( write!(output, "0x00000000, ")?; } - write!(output, "]),\n")?; + writeln!(output, "]),")?; } - write!(output, "];\n\n")?; + writeln!(output, "];")?; + writeln!(output)?; - write!(output, "pub const TILE_DATA: &'static [u32] = &[\n",)?; + writeln!(output, "pub const TILE_DATA: &'static [u32] = &[",)?; let tile_size = tile_size.to_size(); @@ -43,9 +44,9 @@ pub(crate) fn generate_code( for x in 0..tiles_x { let palette_index = results.assignments[y * tiles_x + x]; let palette = &results.optimised_palettes[palette_index]; - write!( + writeln!( output, - " /* {}, {} (palette index {}) */\n", + " /* {}, {} (palette index {}) */", x, y, palette_index )?; @@ -68,11 +69,12 @@ pub(crate) fn generate_code( } } - write!(output, "\n")?; + writeln!(output)?; } } - write!(output, "];\n\n")?; + writeln!(output, "];")?; + writeln!(output)?; write!(output, "pub const PALETTE_ASSIGNMENT: &'static [u8] = &[")?; @@ -83,7 +85,7 @@ pub(crate) fn generate_code( write!(output, "{}, ", assignment)?; } - write!(output, "\n];\n")?; + writeln!(output, "\n];")?; Ok(()) }