From e20b9aef72bf5eaa50b97b9dfe70740368a4b62e Mon Sep 17 00:00:00 2001 From: Rudxain <76864299+Rudxain@users.noreply.github.com> Date: Thu, 27 Mar 2025 18:46:08 -0400 Subject: [PATCH] fix(views:about): default text for `adb version` failure regression introduced here: 3cc2f1d0043708a333631ec52deedccc35b24ad2 --- src/gui/views/about.rs | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/gui/views/about.rs b/src/gui/views/about.rs index 8867d96..8413e69 100644 --- a/src/gui/views/about.rs +++ b/src/gui/views/about.rs @@ -94,19 +94,23 @@ impl About { the numbers will be out of sync! However, the server will still be the "old" version - until the next start + until it's killed */ - let adb_version_text = text( - adb::ACommand::new() - .version() - .map_err(|e| error!("{e}")) - .ok() - // 1st line is the relevant one. - // 2nd could be useful, too - .unwrap_or_default()[0] - // there must be some way to avoid this... - .clone(), - ) + let adb_version_text = text(match adb::ACommand::new().version() { + Ok(s) => s + .lines() + .nth(0) + .unwrap_or_else(|| unreachable!()) + // This allocation is good. + // If it was a ref, the app would hold the entire string + // instead of the relevant slice. + .to_string(), + Err(e) => { + error!("{e}"); + "Couldn't fetch ADB version. Is it installed?".into() + // satisfy `match` by inferring the type of the `Ok` arm + } + }) .width(250); let adb_version_row = row![adb_version_text] .align_items(Alignment::Center)