| 1 |
// examples/arch.rs |
| 2 |
// * use `cargo run --example arch` to execute this example |
| 3 |
|
| 4 |
// spell-checker:ignore (API) nodename osname sysname |
| 5 |
|
| 6 |
use platform_info::{PlatformInfo, PlatformInfoAPI, UNameAPI}; |
| 7 |
|
| 8 |
fn main() { |
| 9 |
let info = PlatformInfo::new().unwrap_or_else(|err| { |
| 10 |
eprintln!("Unable to determine platform info: {err}"); |
| 11 |
std::process::exit(1); |
| 12 |
}); |
| 13 |
println!( |
| 14 |
"{}", |
| 15 |
match info.machine().to_os_string().into_string() { |
| 16 |
Ok(s) => s, |
| 17 |
Err(os_s) => { |
| 18 |
let s = os_s.to_string_lossy(); |
| 19 |
eprintln!("machine = [{}]'{:?}' => '{}'", os_s.len(), os_s, s); |
| 20 |
String::from(s) |
| 21 |
} |
| 22 |
} |
| 23 |
); |
| 24 |
} |