chore: fix clippy warnings and update docs to match public API
Some checks failed
CI / rust (push) Has been cancelled

Fix 9 clippy warnings across mmc5 mapper and desktop frontend.
Sync api_contract.md and architecture.md with actual public surface.
This commit is contained in:
2026-03-16 15:05:02 +03:00
parent 188444f987
commit ea0c5b1894
4 changed files with 48 additions and 29 deletions

View File

@@ -21,8 +21,6 @@ const TITLE: &str = "NES Emulator";
const SCALE: i32 = 3;
const SAMPLE_RATE: u32 = 48_000;
const AUDIO_RING_CAPACITY: usize = 4096;
const AUDIO_CALLBACK_FRAMES: u32 = 256;
fn main() {
if std::env::var_os("GSK_RENDERER").is_none() {
unsafe {
@@ -161,7 +159,7 @@ fn build_ui(app: &gtk::Application, initial_rom: Option<PathBuf>) {
.expect("Failed to create Cairo surface");
// Fill background black
let _ = cr.set_source_rgb(0.0, 0.0, 0.0);
cr.set_source_rgb(0.0, 0.0, 0.0);
let _ = cr.paint();
let sx = width as f64 / FRAME_WIDTH as f64;
@@ -170,8 +168,8 @@ fn build_ui(app: &gtk::Application, initial_rom: Option<PathBuf>) {
let offset_x = (width as f64 - FRAME_WIDTH as f64 * scale) / 2.0;
let offset_y = (height as f64 - FRAME_HEIGHT as f64 * scale) / 2.0;
let _ = cr.translate(offset_x, offset_y);
let _ = cr.scale(scale, scale);
cr.translate(offset_x, offset_y);
cr.scale(scale, scale);
let _ = cr.set_source_surface(&surface, 0.0, 0.0);
cr.source().set_filter(cairo::Filter::Nearest);
let _ = cr.paint();
@@ -249,16 +247,16 @@ fn build_ui(app: &gtk::Application, initial_rom: Option<PathBuf>) {
let scheduler = Rc::clone(&scheduler);
let sync_ui = Rc::clone(&sync_ui);
chooser.connect_response(move |dialog, response| {
if response == gtk::ResponseType::Accept {
if let Some(path) = dialog.file().and_then(|f| f.path()) {
let mut app_state = desktop.borrow_mut();
if let Err(err) = app_state.load_rom_from_path(&path) {
eprintln!("Failed to load ROM '{}': {err}", path.display());
} else {
scheduler.borrow_mut().reset_timing();
let name = rom_filename(&path);
sync_ui(&app_state, Some(&name));
}
if response == gtk::ResponseType::Accept
&& let Some(path) = dialog.file().and_then(|f| f.path())
{
let mut app_state = desktop.borrow_mut();
if let Err(err) = app_state.load_rom_from_path(&path) {
eprintln!("Failed to load ROM '{}': {err}", path.display());
} else {
scheduler.borrow_mut().reset_timing();
let name = rom_filename(&path);
sync_ui(&app_state, Some(&name));
}
}
});
@@ -370,18 +368,18 @@ fn build_ui(app: &gtk::Application, initial_rom: Option<PathBuf>) {
let sync_ui = Rc::clone(&sync_ui);
let drop_target = gtk::DropTarget::new(gio::File::static_type(), gdk::DragAction::COPY);
drop_target.connect_drop(move |_, value, _, _| {
if let Ok(file) = value.get::<gio::File>() {
if let Some(path) = file.path() {
let mut app_state = desktop.borrow_mut();
if let Err(err) = app_state.load_rom_from_path(&path) {
eprintln!("Failed to load ROM '{}': {err}", path.display());
return false;
}
scheduler.borrow_mut().reset_timing();
let name = rom_filename(&path);
sync_ui(&app_state, Some(&name));
return true;
if let Ok(file) = value.get::<gio::File>()
&& let Some(path) = file.path()
{
let mut app_state = desktop.borrow_mut();
if let Err(err) = app_state.load_rom_from_path(&path) {
eprintln!("Failed to load ROM '{}': {err}", path.display());
return false;
}
scheduler.borrow_mut().reset_timing();
let name = rom_filename(&path);
sync_ui(&app_state, Some(&name));
return true;
}
false
});
@@ -716,7 +714,6 @@ impl DesktopApp {
Err(err) => {
eprintln!("Frame execution error: {err}");
self.state = EmulationState::Paused;
return;
}
}
}