Skip to content

Commit

Permalink
feat(common): fallback to std::env::consts::ARCH for System::cpu_arch
Browse files Browse the repository at this point in the history
  • Loading branch information
TrentGL committed Oct 7, 2024
1 parent e022ae4 commit 9ae2b39
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/common/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -777,8 +777,8 @@ impl System {
///
/// println!("CPU Architecture: {:?}", System::cpu_arch());
/// ```
pub fn cpu_arch() -> Option<String> {
SystemInner::cpu_arch()
pub fn cpu_arch() -> String {
SystemInner::cpu_arch().unwrap_or_else(|| std::env::consts::ARCH.to_owned())
}
}

Expand Down Expand Up @@ -2462,7 +2462,7 @@ mod test {

#[test]
fn check_cpu_arch() {
assert_eq!(System::cpu_arch().is_some(), IS_SUPPORTED_SYSTEM);
assert_eq!(!System::cpu_arch().is_empty(), IS_SUPPORTED_SYSTEM);
}

// Ensure that the CPUs frequency isn't retrieved until we ask for it.
Expand Down

0 comments on commit 9ae2b39

Please sign in to comment.