Skip to content

Commit

Permalink
lint: fixed lints
Browse files Browse the repository at this point in the history
  • Loading branch information
lukexor committed Nov 20, 2024
1 parent adc5673 commit f7ca85e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 14 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }})
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tetanes/src/nes/audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions tetanes/src/nes/emulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ impl Emulation {
cfg: &Config,
) -> anyhow::Result<Self> {
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 {
Expand Down Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion tetanes/src/nes/renderer/gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion tetanes/src/nes/renderer/gui/keybinds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
}
Expand Down
8 changes: 4 additions & 4 deletions tetanes/src/nes/renderer/gui/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub fn cursor_to_zapper(x: f32, y: f32, rect: Rect) -> Option<Pos2> {

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
}),
Expand All @@ -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
}),
Expand Down

0 comments on commit f7ca85e

Please sign in to comment.