Skip to content

Commit

Permalink
Split Linux's and Android's long_os_version into separate functions
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Dec 13, 2024
1 parent 4fc41f0 commit ddd4dc0
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/unix/linux/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,14 +385,26 @@ impl SystemInner {
get_system_info_android(InfoType::Name)
}

#[cfg(not(target_os = "android"))]
pub(crate) fn long_os_version() -> Option<String> {
#[cfg(target_os = "android")]
let system_name = "Android";
let mut long_name = "Linux".to_owned();

#[cfg(not(target_os = "android"))]
let system_name = "Linux";
if let Some(os_version) = Self::os_version() {
long_name.push(' ');
long_name.push_str(&os_version);
}

let mut long_name = system_name.to_owned();
if let Some(short_name) = Self::name() {
long_name.push(' ');
long_name.push_str(&short_name);
}

Some(long_name)
}

#[cfg(target_os = "android")]
pub(crate) fn long_os_version() -> Option<String> {
let mut long_name = "Android".to_owned();

if let Some(os_version) = Self::os_version() {
long_name.push(' ');
Expand Down

0 comments on commit ddd4dc0

Please sign in to comment.