From 9f101397d0f187c5fea452019c2479056ac1728b Mon Sep 17 00:00:00 2001 From: Miguel Palhas Date: Sun, 15 Nov 2026 13:19:59 +0000 Subject: [PATCH] chore: satisfy clippy map_unwrap_or on rust 1.100 Co-Authored-By: Claude Opus 5.5 --- crates/arr-api/src/health.rs | 3 +-- crates/arr-api/src/subtitles.rs | 5 +---- crates/arr-daemon/src/qbit_fake.rs | 8 +++----- crates/arr-meta/src/model.rs | 33 ++++++++++++++---------------- 4 files changed, 20 insertions(+), 29 deletions(-) diff --git a/crates/arr-api/src/health.rs b/crates/arr-api/src/health.rs index 5ae952c..d14a35f 100644 --- a/crates/arr-api/src/health.rs +++ b/crates/arr-api/src/health.rs @@ -243,8 +243,7 @@ async fn probe_subtitles(state: &AppState) -> SubtitleHealth { // quiet rather than failing on data the operator has not entered yet. let enabled = settings .as_ref() - .map(|settings| settings.providers_enabled.as_slice()) - .unwrap_or_default(); + .map_or_default(|settings| settings.providers_enabled.as_slice()); let engine = settings .as_ref() .and_then(|settings| settings.translation_engine.as_deref()); diff --git a/crates/arr-api/src/subtitles.rs b/crates/arr-api/src/subtitles.rs index 8412b0b..66e04ce 100644 --- a/crates/arr-api/src/subtitles.rs +++ b/crates/arr-api/src/subtitles.rs @@ -641,10 +641,7 @@ async fn embedded_tracks_of( .fetch_optional(pool(state)?) .await? .flatten(); - Ok(probed - .as_deref() - .map(extractable_tracks) - .unwrap_or_default()) + Ok(probed.as_deref().map_or_default(extractable_tracks)) } /// The `sub_tracks` array of a `probed` blob, filtered to what ยง15 allows an diff --git a/crates/arr-daemon/src/qbit_fake.rs b/crates/arr-daemon/src/qbit_fake.rs index acca1a6..7ebfc9f 100644 --- a/crates/arr-daemon/src/qbit_fake.rs +++ b/crates/arr-daemon/src/qbit_fake.rs @@ -165,14 +165,13 @@ impl FakeQbit { .torrents() .into_iter() .find(|torrent| torrent.hash.eq_ignore_ascii_case(&hash)) - .map(|torrent| { + .map_or_default(|torrent| { torrent .files .into_iter() .map(|(path, size)| json!({"name": path, "size": size})) .collect() - }) - .unwrap_or_default(); + }); ResponseTemplate::new(200).set_body_json(files) } @@ -281,8 +280,7 @@ fn decode(input: &str) -> String { fn text(parts: &HashMap>, key: &str) -> String { parts .get(key) - .map(|bytes| String::from_utf8_lossy(bytes).into_owned()) - .unwrap_or_default() + .map_or_default(|bytes| String::from_utf8_lossy(bytes).into_owned()) } /// The named parts of a `multipart/form-data` body. diff --git a/crates/arr-meta/src/model.rs b/crates/arr-meta/src/model.rs index cc46796..65c4c48 100644 --- a/crates/arr-meta/src/model.rs +++ b/crates/arr-meta/src/model.rs @@ -787,21 +787,19 @@ impl From for Video { } fn cast_from(raw: Option) -> Vec { - let mut cast: Vec = raw - .map(|credits| { - credits - .cast - .into_iter() - .map(|member| CastMember { - tmdb_id: member.id, - name: member.name, - character: member.character, - profile_path: non_empty(member.profile_path), - order: member.order, - }) - .collect() - }) - .unwrap_or_default(); + let mut cast: Vec = raw.map_or_default(|credits| { + credits + .cast + .into_iter() + .map(|member| CastMember { + tmdb_id: member.id, + name: member.name, + character: member.character, + profile_path: non_empty(member.profile_path), + order: member.order, + }) + .collect() + }); // TMDB's own ordering is by `order`; sorting makes the truncation hold // even if a fixture or future API revision sends them shuffled. cast.sort_by_key(|member| member.order); @@ -810,9 +808,8 @@ fn cast_from(raw: Option) -> Vec { } fn trailer_from(raw: Option) -> Option