File: arch.rs

package info (click to toggle)
rust-platform-info 2.0.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 264 kB
  • sloc: makefile: 2
file content (24 lines) | stat: -rw-r--r-- 703 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// examples/arch.rs
// * use `cargo run --example arch` to execute this example

// spell-checker:ignore (API) nodename osname sysname

use platform_info::{PlatformInfo, PlatformInfoAPI, UNameAPI};

fn main() {
    let info = PlatformInfo::new().unwrap_or_else(|err| {
        eprintln!("Unable to determine platform info: {err}");
        std::process::exit(1);
    });
    println!(
        "{}",
        match info.machine().to_os_string().into_string() {
            Ok(s) => s,
            Err(os_s) => {
                let s = os_s.to_string_lossy();
                eprintln!("machine = [{}]'{:?}' => '{}'", os_s.len(), os_s, s);
                String::from(s)
            }
        }
    );
}