Skip to content

Commit 90504d8

Browse files
committed
chore: satisfy lints added in rust 1.95
1 parent 58595bf commit 90504d8

2 files changed

Lines changed: 26 additions & 53 deletions

File tree

src/app.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -760,17 +760,12 @@ impl App {
760760
if self.controllers.is_empty() {
761761
self.controller_state.select(None);
762762
} else {
763-
let i = match self.controller_state.selected() {
764-
Some(i) => {
765-
if i > 0 {
766-
(i - 1).min(self.controllers.len() - 1)
767-
} else {
768-
0
769-
}
770-
}
771-
None => 0,
763+
let next_i = if let Some(i) = self.controller_state.selected() {
764+
(i - 1).min(self.controllers.len() - 1)
765+
} else {
766+
0
772767
};
773-
self.controller_state.select(Some(i));
768+
self.controller_state.select(Some(next_i));
774769
}
775770
}
776771

src/handler.rs

Lines changed: 21 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -320,21 +320,13 @@ pub async fn handle_key_events(
320320

321321
// scroll down
322322
KeyCode::Char('j') | KeyCode::Down => match app.focused_block {
323-
FocusedBlock::Adapter => {
324-
if !app.controllers.is_empty() {
325-
let i = match app.controller_state.selected() {
326-
Some(i) => {
327-
if i < app.controllers.len() - 1 {
328-
i + 1
329-
} else {
330-
0
331-
}
332-
}
333-
None => 0,
334-
};
323+
FocusedBlock::Adapter if !app.controllers.is_empty() => {
324+
let i = match app.controller_state.selected() {
325+
Some(i) if i < app.controllers.len() - 1 => i + 1,
326+
_ => 0,
327+
};
335328

336-
app.controller_state.select(Some(i));
337-
}
329+
app.controller_state.select(Some(i));
338330
}
339331

340332
FocusedBlock::PairedDevices => {
@@ -343,14 +335,8 @@ pub async fn handle_key_events(
343335

344336
if !controller.paired_devices.is_empty() {
345337
let i = match app.paired_devices_state.selected() {
346-
Some(i) => {
347-
if i < controller.paired_devices.len() - 1 {
348-
i + 1
349-
} else {
350-
0
351-
}
352-
}
353-
None => 0,
338+
Some(i) if i < controller.paired_devices.len() - 1 => i + 1,
339+
_ => 0,
354340
};
355341

356342
app.paired_devices_state.select(Some(i));
@@ -364,14 +350,8 @@ pub async fn handle_key_events(
364350

365351
if !controller.new_devices.is_empty() {
366352
let i = match app.new_devices_state.selected() {
367-
Some(i) => {
368-
if i < controller.new_devices.len() - 1 {
369-
i + 1
370-
} else {
371-
0
372-
}
373-
}
374-
None => 0,
353+
Some(i) if i < controller.new_devices.len() - 1 => i + 1,
354+
_ => 0,
375355
};
376356

377357
app.new_devices_state.select(Some(i));
@@ -384,21 +364,19 @@ pub async fn handle_key_events(
384364

385365
// scroll up
386366
KeyCode::Char('k') | KeyCode::Up => match app.focused_block {
387-
FocusedBlock::Adapter => {
388-
if !app.controllers.is_empty() {
389-
let i = match app.controller_state.selected() {
390-
Some(i) => {
391-
if i > 0 {
392-
i - 1
393-
} else {
394-
app.controllers.len() - 1
395-
}
367+
FocusedBlock::Adapter if !app.controllers.is_empty() => {
368+
let i = match app.controller_state.selected() {
369+
Some(i) => {
370+
if i > 0 {
371+
i - 1
372+
} else {
373+
app.controllers.len() - 1
396374
}
397-
None => 0,
398-
};
375+
}
376+
None => 0,
377+
};
399378

400-
app.controller_state.select(Some(i));
401-
}
379+
app.controller_state.select(Some(i));
402380
}
403381

404382
FocusedBlock::PairedDevices => {

0 commit comments

Comments
 (0)