From 1c9082049cbd67bad3f61e17cc95e23ddab16815 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 13 Dec 2024 16:31:22 -0800 Subject: [PATCH] Prefix distro version with "unknown" if distro name is not known --- src/unix/linux/system.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/unix/linux/system.rs b/src/unix/linux/system.rs index 62d474859..24595927c 100644 --- a/src/unix/linux/system.rs +++ b/src/unix/linux/system.rs @@ -395,16 +395,17 @@ impl SystemInner { let distro_name = Self::name(); let distro_version = Self::os_version(); - if let (Some(distro_name), Some(distro_version)) = (&distro_name, &distro_version) { + if let Some(distro_version) = &distro_version { // "Linux (Ubuntu 24.04)" long_name.push_str(" ("); - long_name.push_str(distro_name); + long_name.push_str(distro_name.as_deref().unwrap_or("unknown")); long_name.push(' '); long_name.push_str(distro_version); long_name.push(')'); - } else if let Some(distro_or_version) = distro_name.or(distro_version) { + } else if let Some(distro_name) = &distro_name { + // "Linux (Ubuntu)" long_name.push_str(" ("); - long_name.push_str(&distro_or_version); + long_name.push_str(distro_name); long_name.push(')'); }