From 4179b0ec2883ac32489237cd618d02bbbb0d4ff0 Mon Sep 17 00:00:00 2001 From: Muhammad Nauman Raza Date: Fri, 22 Mar 2024 19:50:34 +0000 Subject: [PATCH] refactor: clippy autofix Former-commit-id: da7665869588cdb52e96ceeb2edcb7e7c13a4d44 Former-commit-id: 785d0e54cf09f781feecffd6512f3353d6b150e5 --- platform/rustboyadvance-sdl2/src/audio.rs | 1 - platform/rustboyadvance-sdl2/src/input.rs | 1 - platform/rustboyadvance-sdl2/src/main.rs | 15 ++++++--------- platform/rustboyadvance-sdl2/src/options.rs | 2 +- platform/rustboyadvance-sdl2/src/video.rs | 4 ++-- 5 files changed, 9 insertions(+), 14 deletions(-) diff --git a/platform/rustboyadvance-sdl2/src/audio.rs b/platform/rustboyadvance-sdl2/src/audio.rs index f106c97..6e982d3 100644 --- a/platform/rustboyadvance-sdl2/src/audio.rs +++ b/platform/rustboyadvance-sdl2/src/audio.rs @@ -1,4 +1,3 @@ -use sdl2; use sdl2::audio::{AudioCallback, AudioDevice, AudioFormat, AudioSpec, AudioSpecDesired}; use rustboyadvance_core::prelude::SimpleAudioInterface; diff --git a/platform/rustboyadvance-sdl2/src/input.rs b/platform/rustboyadvance-sdl2/src/input.rs index cabb32a..cc8c028 100644 --- a/platform/rustboyadvance-sdl2/src/input.rs +++ b/platform/rustboyadvance-sdl2/src/input.rs @@ -4,7 +4,6 @@ use sdl2::keyboard::Scancode; use rustboyadvance_core::keypad as gba_keypad; -use bit; use bit::BitIndex; pub fn on_keyboard_key_down(key_state: &mut u16, scancode: Scancode) { diff --git a/platform/rustboyadvance-sdl2/src/main.rs b/platform/rustboyadvance-sdl2/src/main.rs index 88291c2..69ad196 100644 --- a/platform/rustboyadvance-sdl2/src/main.rs +++ b/platform/rustboyadvance-sdl2/src/main.rs @@ -3,8 +3,6 @@ use sdl2::event::Event; use sdl2::keyboard::Scancode; use sdl2::{self}; -use bytesize; -use spin_sleep; use structopt::StructOpt; use std::fs; @@ -14,7 +12,6 @@ use std::time; #[macro_use] extern crate log; -use flexi_logger; use flexi_logger::*; mod audio; @@ -29,7 +26,7 @@ use rustboyadvance_utils::FpsCounter; const LOG_DIR: &str = ".logs"; fn ask_download_bios() { - const OPEN_SOURCE_BIOS_URL: &'static str = + const OPEN_SOURCE_BIOS_URL: &str = "https://github.com/Nebuleon/ReGBA/raw/master/bios/gba_bios.bin"; println!("Missing BIOS file. If you don't have the original GBA BIOS, you can download an open-source bios from {}", OPEN_SOURCE_BIOS_URL); std::process::exit(0); @@ -46,7 +43,7 @@ fn load_bios(bios_path: &Path) -> Box<[u8]> { } fn main() -> Result<(), Box> { - fs::create_dir_all(LOG_DIR).expect(&format!("could not create log directory ({})", LOG_DIR)); + fs::create_dir_all(LOG_DIR).unwrap_or_else(|_| panic!("could not create log directory ({})", LOG_DIR)); flexi_logger::Logger::with_env_or_str("info") .log_to_file() .directory(LOG_DIR) @@ -84,7 +81,7 @@ fn main() -> Result<(), Box> { let mut renderer = video::init(&sdl_context)?; let (audio_interface, mut _sdl_audio_device) = audio::create_audio_player(&sdl_context)?; - let mut rom_name = opts.rom_name(); + let rom_name = opts.rom_name(); let bios_bin = load_bios(&opts.bios); @@ -194,9 +191,9 @@ fn main() -> Result<(), Box> { }; if removed { let name = active_controller - .and_then(|controller| Some(controller.name())) + .map(|controller| Some(controller.name())) .unwrap(); - info!("Removing game controller: {}", name); + info!("Removing game controller: {:?}", name); active_controller = None; } } @@ -208,7 +205,7 @@ fn main() -> Result<(), Box> { } } Event::Quit { .. } => break 'running, - Event::DropFile { filename, .. } => { + Event::DropFile { .. } => { todo!("impl DropFile again") } _ => {} diff --git a/platform/rustboyadvance-sdl2/src/options.rs b/platform/rustboyadvance-sdl2/src/options.rs index eca65d7..ae06bec 100644 --- a/platform/rustboyadvance-sdl2/src/options.rs +++ b/platform/rustboyadvance-sdl2/src/options.rs @@ -1,4 +1,4 @@ -use std::{io, path::PathBuf}; +use std::{path::PathBuf}; use rustboyadvance_core::{ cartridge::{BackupType, GamepakBuilder}, diff --git a/platform/rustboyadvance-sdl2/src/video.rs b/platform/rustboyadvance-sdl2/src/video.rs index 90e7218..1bc5f84 100644 --- a/platform/rustboyadvance-sdl2/src/video.rs +++ b/platform/rustboyadvance-sdl2/src/video.rs @@ -22,7 +22,7 @@ pub struct Renderer<'a> { image_context: Sdl2ImageContext, } -pub fn init<'a>(sdl_context: &'a Sdl) -> Result, Box> { +pub fn init(sdl_context: &Sdl) -> Result, Box> { let video_subsystem = sdl_context.video()?; let image_context = sdl2::image::init(InitFlag::PNG | InitFlag::JPG)?; let mut window = video_subsystem @@ -57,7 +57,7 @@ pub fn init<'a>(sdl_context: &'a Sdl) -> Result, Box Renderer<'a> { pub fn set_window_title(&mut self, title: &str) { - self.canvas.window_mut().set_title(&title).unwrap(); + self.canvas.window_mut().set_title(title).unwrap(); } pub fn render(&mut self, buffer: &[u32]) {