diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 61263742..84dbefdc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,7 +46,7 @@ jobs: components: clippy - uses: Swatinem/rust-cache@v2 - run: | - cargo clippy -p tetanes --target wasm32-unknown-unknown --all-features --keep-going -- -D warnings + cargo clippy --lib --bin tetanes --target wasm32-unknown-unknown --all-features --keep-going -- -D warnings lint-tetanes: name: Lint TetaNES (${{ matrix.os }}) @@ -104,6 +104,7 @@ jobs: - uses: Swatinem/rust-cache@v2 - run: | sudo apt update + sudo apt install -y libudev-dev libasound2-dev - run: | cargo test -p tetanes --all-features --no-fail-fast @@ -119,9 +120,7 @@ jobs: toolchain: stable - uses: Swatinem/rust-cache@v2 - run: | - sudo apt update - - run: | - cargo test --lib tetanes-core --all-features --no-fail-fast + cargo test -p tetanes-core --all-features --no-fail-fast docs: name: Docs diff --git a/tetanes/src/nes/audio.rs b/tetanes/src/nes/audio.rs index d7a3fbcc..4eee8140 100644 --- a/tetanes/src/nes/audio.rs +++ b/tetanes/src/nes/audio.rs @@ -95,7 +95,7 @@ impl Audio { .output .as_ref() .and_then(|output| output.mixer.as_ref()) - .map_or(false, |mixer| !mixer.paused) + .is_some_and(|mixer| !mixer.paused) } /// Set whether the audio mixer is enabled. Returns [`State`] representing the state of @@ -186,7 +186,7 @@ impl Audio { self.output .as_ref() .and_then(|output| output.mixer.as_ref()) - .map_or(false, |mixer| mixer.recording.is_some()) + .is_some_and(|mixer| mixer.recording.is_some()) } /// Start recording audio to a file. diff --git a/tetanes/src/nes/emulation.rs b/tetanes/src/nes/emulation.rs index 7d16ec16..49cdc30f 100644 --- a/tetanes/src/nes/emulation.rs +++ b/tetanes/src/nes/emulation.rs @@ -209,7 +209,7 @@ impl Emulation { cfg: &Config, ) -> anyhow::Result { let threaded = cfg.emulation.threaded - && std::thread::available_parallelism().map_or(false, |count| count.get() > 1); + && std::thread::available_parallelism().is_ok_and(|count| count.get() > 1); let backend = if threaded { Threads::Multi(Multi::spawn(tx, frame_tx, cfg)?) } else { @@ -323,7 +323,7 @@ impl State { frame_time_diag: FrameTimeDiag::new(), run_state: RunState::Paused, threaded: cfg.emulation.threaded - && std::thread::available_parallelism().map_or(false, |count| count.get() > 1), + && std::thread::available_parallelism().is_ok_and(|count| count.get() > 1), rewinding: false, rewind, record: Record::new(), diff --git a/tetanes/src/nes/renderer/gui.rs b/tetanes/src/nes/renderer/gui.rs index 3a116e1e..55b2bc36 100644 --- a/tetanes/src/nes/renderer/gui.rs +++ b/tetanes/src/nes/renderer/gui.rs @@ -1257,7 +1257,7 @@ impl Gui { if self .cfg .action_input(DeckAction::ZapperAimOffscreen) - .map_or(false, |input| input_down(ui, gamepads, &self.cfg, input)) + .is_some_and(|input| input_down(ui, gamepads, &self.cfg, input)) { let pos = (Ppu::WIDTH + 10, Ppu::HEIGHT + 10); tx.event(EmulationEvent::ZapperAim(pos)); diff --git a/tetanes/src/nes/renderer/gui/keybinds.rs b/tetanes/src/nes/renderer/gui/keybinds.rs index 1326ff7e..02a13bd4 100644 --- a/tetanes/src/nes/renderer/gui/keybinds.rs +++ b/tetanes/src/nes/renderer/gui/keybinds.rs @@ -84,7 +84,7 @@ impl Keybinds { } pub fn wants_input(&self) -> bool { - self.state.try_lock().map_or(false, |state| { + self.state.try_lock().is_some_and(|state| { state.pending_input.is_some() || state.gamepad_unassign_confirm.is_some() }) } diff --git a/tetanes/src/nes/renderer/gui/lib.rs b/tetanes/src/nes/renderer/gui/lib.rs index 6e9ab3d2..592f910f 100644 --- a/tetanes/src/nes/renderer/gui/lib.rs +++ b/tetanes/src/nes/renderer/gui/lib.rs @@ -59,7 +59,7 @@ pub fn cursor_to_zapper(x: f32, y: f32, rect: Rect) -> Option { pub fn input_down(ui: &mut Ui, gamepads: Option<&Gamepads>, cfg: &Config, input: Input) -> bool { ui.input_mut(|i| match input { - Input::Key(keycode, modifier_state) => key_from_keycode(keycode).map_or(false, |key| { + Input::Key(keycode, modifier_state) => key_from_keycode(keycode).is_some_and(|key| { let modifiers = modifiers_from_modifiers_state(modifier_state); i.key_down(key) && i.modifiers == modifiers }), @@ -68,16 +68,16 @@ pub fn input_down(ui: &mut Ui, gamepads: Option<&Gamepads>, cfg: &Config, input: .gamepad_assigned_to(player) .and_then(|uuid| gamepads.map(|g| g.gamepad_by_uuid(&uuid))) .flatten() - .map_or(false, |g| g.is_pressed(button)), + .is_some_and(|g| g.is_pressed(button)), Input::Mouse(mouse_button) => pointer_button_from_mouse(mouse_button) - .map_or(false, |pointer| i.pointer.button_down(pointer)), + .is_some_and(|pointer| i.pointer.button_down(pointer)), Input::Axis(player, axis, direction) => cfg .input .gamepad_assigned_to(player) .and_then(|uuid| gamepads.map(|g| g.gamepad_by_uuid(&uuid))) .flatten() .and_then(|g| g.axis_data(axis).map(|data| data.value())) - .map_or(false, |value| { + .is_some_and(|value| { let (dir, state) = Gamepads::axis_state(value); dir == Some(direction) && state == ElementState::Pressed }),