refactor: Refactored to use more idiomatic let-else statements where applicable

This commit is contained in:
2025-12-03 15:23:07 -07:00
parent ad58912baf
commit e50fb88bfc
43 changed files with 1337 additions and 1291 deletions
+4 -5
View File
@@ -23,11 +23,10 @@ pub(super) struct EditIndexerUi;
impl DrawUi for EditIndexerUi {
fn accepts(route: Route) -> bool {
if let Route::Sonarr(active_sonarr_block, _) = route {
return EDIT_INDEXER_BLOCKS.contains(&active_sonarr_block);
}
false
let Route::Sonarr(active_sonarr_block, _) = route else {
return false;
};
EDIT_INDEXER_BLOCKS.contains(&active_sonarr_block)
}
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, _area: Rect) {
@@ -23,11 +23,10 @@ pub(super) struct IndexerSettingsUi;
impl DrawUi for IndexerSettingsUi {
fn accepts(route: Route) -> bool {
if let Route::Sonarr(active_sonarr_block, _) = route {
return INDEXER_SETTINGS_BLOCKS.contains(&active_sonarr_block);
}
false
let Route::Sonarr(active_sonarr_block, _) = route else {
return false;
};
INDEXER_SETTINGS_BLOCKS.contains(&active_sonarr_block)
}
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, _area: Rect) {
+4 -5
View File
@@ -30,11 +30,10 @@ pub(super) struct AddSeriesUi;
impl DrawUi for AddSeriesUi {
fn accepts(route: Route) -> bool {
if let Route::Sonarr(active_sonarr_block, _) = route {
return ADD_SERIES_BLOCKS.contains(&active_sonarr_block);
}
false
let Route::Sonarr(active_sonarr_block, _) = route else {
return false;
};
ADD_SERIES_BLOCKS.contains(&active_sonarr_block)
}
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, _area: Rect) {
+4 -5
View File
@@ -17,11 +17,10 @@ pub(super) struct DeleteSeriesUi;
impl DrawUi for DeleteSeriesUi {
fn accepts(route: Route) -> bool {
if let Route::Sonarr(active_sonarr_block, _) = route {
return DELETE_SERIES_BLOCKS.contains(&active_sonarr_block);
}
false
let Route::Sonarr(active_sonarr_block, _) = route else {
return false;
};
DELETE_SERIES_BLOCKS.contains(&active_sonarr_block)
}
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, _area: Rect) {
+4 -5
View File
@@ -32,11 +32,10 @@ pub(super) struct EditSeriesUi;
impl DrawUi for EditSeriesUi {
fn accepts(route: Route) -> bool {
if let Route::Sonarr(active_sonarr_block, _) = route {
return EDIT_SERIES_BLOCKS.contains(&active_sonarr_block);
}
false
let Route::Sonarr(active_sonarr_block, _) = route else {
return false;
};
EDIT_SERIES_BLOCKS.contains(&active_sonarr_block)
}
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, _area: Rect) {
@@ -39,11 +39,10 @@ pub(super) struct EpisodeDetailsUi;
impl DrawUi for EpisodeDetailsUi {
fn accepts(route: Route) -> bool {
if let Route::Sonarr(active_sonarr_block, _) = route {
return EPISODE_DETAILS_BLOCKS.contains(&active_sonarr_block);
}
false
let Route::Sonarr(active_sonarr_block, _) = route else {
return false;
};
EPISODE_DETAILS_BLOCKS.contains(&active_sonarr_block)
}
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, _area: Rect) {
@@ -38,12 +38,10 @@ pub(super) struct SeasonDetailsUi;
impl DrawUi for SeasonDetailsUi {
fn accepts(route: Route) -> bool {
if let Route::Sonarr(active_sonarr_block, _) = route {
return EpisodeDetailsUi::accepts(route)
|| SEASON_DETAILS_BLOCKS.contains(&active_sonarr_block);
}
false
let Route::Sonarr(active_sonarr_block, _) = route else {
return false;
};
EpisodeDetailsUi::accepts(route) || SEASON_DETAILS_BLOCKS.contains(&active_sonarr_block)
}
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, _area: Rect) {
@@ -42,13 +42,12 @@ pub(super) struct SeriesDetailsUi;
impl DrawUi for SeriesDetailsUi {
fn accepts(route: Route) -> bool {
if let Route::Sonarr(active_sonarr_block, _) = route {
return SeasonDetailsUi::accepts(route)
|| EpisodeDetailsUi::accepts(route)
|| SERIES_DETAILS_BLOCKS.contains(&active_sonarr_block);
}
false
let Route::Sonarr(active_sonarr_block, _) = route else {
return false;
};
SeasonDetailsUi::accepts(route)
|| EpisodeDetailsUi::accepts(route)
|| SERIES_DETAILS_BLOCKS.contains(&active_sonarr_block)
}
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
+4 -5
View File
@@ -46,11 +46,10 @@ pub(super) struct SystemUi;
impl DrawUi for SystemUi {
fn accepts(route: Route) -> bool {
if let Route::Sonarr(active_sonarr_block, _) = route {
return SystemDetailsUi::accepts(route) || active_sonarr_block == ActiveSonarrBlock::System;
}
false
let Route::Sonarr(active_sonarr_block, _) = route else {
return false;
};
SystemDetailsUi::accepts(route) || active_sonarr_block == ActiveSonarrBlock::System
}
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
+4 -5
View File
@@ -27,11 +27,10 @@ pub(super) struct SystemDetailsUi;
impl DrawUi for SystemDetailsUi {
fn accepts(route: Route) -> bool {
if let Route::Sonarr(active_sonarr_block, _) = route {
return SYSTEM_DETAILS_BLOCKS.contains(&active_sonarr_block);
}
false
let Route::Sonarr(active_sonarr_block, _) = route else {
return false;
};
SYSTEM_DETAILS_BLOCKS.contains(&active_sonarr_block)
}
fn draw(f: &mut Frame<'_>, app: &mut App<'_>, _area: Rect) {