refactor: clippy autofix

Former-commit-id: da7665869588cdb52e96ceeb2edcb7e7c13a4d44
Former-commit-id: 785d0e54cf09f781feecffd6512f3353d6b150e5
This commit is contained in:
Muhammad Nauman Raza 2024-03-22 19:50:34 +00:00
parent 5a03546a7c
commit 4179b0ec28
5 changed files with 9 additions and 14 deletions

View file

@ -1,4 +1,3 @@
use sdl2;
use sdl2::audio::{AudioCallback, AudioDevice, AudioFormat, AudioSpec, AudioSpecDesired}; use sdl2::audio::{AudioCallback, AudioDevice, AudioFormat, AudioSpec, AudioSpecDesired};
use rustboyadvance_core::prelude::SimpleAudioInterface; use rustboyadvance_core::prelude::SimpleAudioInterface;

View file

@ -4,7 +4,6 @@ use sdl2::keyboard::Scancode;
use rustboyadvance_core::keypad as gba_keypad; use rustboyadvance_core::keypad as gba_keypad;
use bit;
use bit::BitIndex; use bit::BitIndex;
pub fn on_keyboard_key_down(key_state: &mut u16, scancode: Scancode) { pub fn on_keyboard_key_down(key_state: &mut u16, scancode: Scancode) {

View file

@ -3,8 +3,6 @@ use sdl2::event::Event;
use sdl2::keyboard::Scancode; use sdl2::keyboard::Scancode;
use sdl2::{self}; use sdl2::{self};
use bytesize;
use spin_sleep;
use structopt::StructOpt; use structopt::StructOpt;
use std::fs; use std::fs;
@ -14,7 +12,6 @@ use std::time;
#[macro_use] #[macro_use]
extern crate log; extern crate log;
use flexi_logger;
use flexi_logger::*; use flexi_logger::*;
mod audio; mod audio;
@ -29,7 +26,7 @@ use rustboyadvance_utils::FpsCounter;
const LOG_DIR: &str = ".logs"; const LOG_DIR: &str = ".logs";
fn ask_download_bios() { 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"; "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); 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); std::process::exit(0);
@ -46,7 +43,7 @@ fn load_bios(bios_path: &Path) -> Box<[u8]> {
} }
fn main() -> Result<(), Box<dyn std::error::Error>> { fn main() -> Result<(), Box<dyn std::error::Error>> {
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") flexi_logger::Logger::with_env_or_str("info")
.log_to_file() .log_to_file()
.directory(LOG_DIR) .directory(LOG_DIR)
@ -84,7 +81,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut renderer = video::init(&sdl_context)?; let mut renderer = video::init(&sdl_context)?;
let (audio_interface, mut _sdl_audio_device) = audio::create_audio_player(&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); let bios_bin = load_bios(&opts.bios);
@ -194,9 +191,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
}; };
if removed { if removed {
let name = active_controller let name = active_controller
.and_then(|controller| Some(controller.name())) .map(|controller| Some(controller.name()))
.unwrap(); .unwrap();
info!("Removing game controller: {}", name); info!("Removing game controller: {:?}", name);
active_controller = None; active_controller = None;
} }
} }
@ -208,7 +205,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
} }
} }
Event::Quit { .. } => break 'running, Event::Quit { .. } => break 'running,
Event::DropFile { filename, .. } => { Event::DropFile { .. } => {
todo!("impl DropFile again") todo!("impl DropFile again")
} }
_ => {} _ => {}

View file

@ -1,4 +1,4 @@
use std::{io, path::PathBuf}; use std::{path::PathBuf};
use rustboyadvance_core::{ use rustboyadvance_core::{
cartridge::{BackupType, GamepakBuilder}, cartridge::{BackupType, GamepakBuilder},

View file

@ -22,7 +22,7 @@ pub struct Renderer<'a> {
image_context: Sdl2ImageContext, image_context: Sdl2ImageContext,
} }
pub fn init<'a>(sdl_context: &'a Sdl) -> Result<Renderer<'a>, Box<dyn std::error::Error>> { pub fn init(sdl_context: &Sdl) -> Result<Renderer<'_>, Box<dyn std::error::Error>> {
let video_subsystem = sdl_context.video()?; let video_subsystem = sdl_context.video()?;
let image_context = sdl2::image::init(InitFlag::PNG | InitFlag::JPG)?; let image_context = sdl2::image::init(InitFlag::PNG | InitFlag::JPG)?;
let mut window = video_subsystem let mut window = video_subsystem
@ -57,7 +57,7 @@ pub fn init<'a>(sdl_context: &'a Sdl) -> Result<Renderer<'a>, Box<dyn std::error
impl<'a> Renderer<'a> { impl<'a> Renderer<'a> {
pub fn set_window_title(&mut self, title: &str) { 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]) { pub fn render(&mut self, buffer: &[u32]) {