From 13398a5f4872d66243cb37c6eddbdc4aefa83a37 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= <joamag@gmail.com>
Date: Sun, 30 Apr 2023 12:23:49 +0100
Subject: [PATCH] fix: all pending clippy issues

---
 frontends/sdl/src/main.rs |  2 +-
 src/gb.rs                 | 20 +++++++++++++-------
 src/rom.rs                | 15 ++++++++++-----
 3 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/frontends/sdl/src/main.rs b/frontends/sdl/src/main.rs
index 0e7e630f..d1fdf4a0 100644
--- a/frontends/sdl/src/main.rs
+++ b/frontends/sdl/src/main.rs
@@ -474,7 +474,7 @@ fn main() {
     // parses the provided command line arguments and uses them to
     // obtain structured values
     let args = Args::parse();
-    let mode: GameBoyMode = GameBoyMode::from_str(&args.mode);
+    let mode: GameBoyMode = GameBoyMode::from_string(&args.mode);
 
     // creates a new Game Boy instance and loads both the boot ROM
     // and the initial game ROM to "start the engine"
diff --git a/src/gb.rs b/src/gb.rs
index 5f8b01c3..867e6b0f 100644
--- a/src/gb.rs
+++ b/src/gb.rs
@@ -66,7 +66,7 @@ impl GameBoyMode {
         }
     }
 
-    pub fn from_str(value: &str) -> GameBoyMode {
+    pub fn from_string(value: &str) -> GameBoyMode {
         match value {
             "dmg" => GameBoyMode::Dmg,
             "cgb" => GameBoyMode::Cgb,
@@ -627,19 +627,25 @@ impl GameBoy {
     }
 
     pub fn description(&self, column_length: usize) -> String {
+        let version_l = format!("{:width$}", "Version", width = column_length);
+        let mode_l = format!("{:width$}", "Mode", width = column_length);
+        let clock_l = format!("{:width$}", "Clock", width = column_length);
+        let ram_size_l = format!("{:width$}", "RAM Size", width = column_length);
+        let vram_size_l = format!("{:width$}", "VRAM Size", width = column_length);
+        let serial_l = format!("{:width$}", "Serial", width = column_length);
         format!(
             "{}  {}\n{}  {}\n{}  {}\n{}  {}\n{}  {}\n{}  {}",
-            format!("{:width$}", "Version", width = column_length),
+            version_l,
             VERSION,
-            format!("{:width$}", "Mode", width = column_length),
+            mode_l,
             self.mode(),
-            format!("{:width$}", "Clock", width = column_length),
+            clock_l,
             self.clock_freq_s(),
-            format!("{:width$}", "RAM Size", width = column_length),
+            ram_size_l,
             self.ram_size(),
-            format!("{:width$}", "VRAM Size", width = column_length),
+            vram_size_l,
             self.vram_size(),
-            format!("{:width$}", "Serial", width = column_length),
+            serial_l,
             self.serial_i().device().description(),
         )
     }
diff --git a/src/rom.rs b/src/rom.rs
index c9acccf5..f8293632 100644
--- a/src/rom.rs
+++ b/src/rom.rs
@@ -503,17 +503,22 @@ impl Cartridge {
     }
 
     pub fn description(&self, column_length: usize) -> String {
+        let name_l = format!("{:width$}", "Name", width = column_length);
+        let type_l = format!("{:width$}", "Type", width = column_length);
+        let rom_size_l = format!("{:width$}", "ROM Size", width = column_length);
+        let ram_size_l = format!("{:width$}", "RAM Size", width = column_length);
+        let cgb_l = format!("{:width$}", "CGB Mode", width = column_length);
         format!(
             "{}  {}\n{}  {}\n{}  {}\n{}  {}\n{}  {}",
-            format!("{:width$}", "Name", width = column_length),
+            name_l,
             self.title(),
-            format!("{:width$}", "Type", width = column_length),
+            type_l,
             self.rom_type(),
-            format!("{:width$}", "ROM Size", width = column_length),
+            rom_size_l,
             self.rom_size(),
-            format!("{:width$}", "RAM Size", width = column_length),
+            ram_size_l,
             self.ram_size(),
-            format!("{:width$}", "CGB Mode", width = column_length),
+            cgb_l,
             self.cgb_flag()
         )
     }
-- 
GitLab