| 1 | // examples/ex.rs |
| 2 | // * use `cargo run --example ex` to execute this example |
| 3 | |
| 4 | // spell-checker:ignore (API) nodename osname sysname |
| 5 | |
| 6 | use platform_inforust-analyzer cargo platform-info 2.0.5 crate/::{PlatformInforust-analyzer cargo platform-info 2.0.5 lib_impl/target/PlatformInfo#, PlatformInfoAPIrust-analyzer cargo platform-info 2.0.5 PlatformInfoAPI#, UNameAPIrust-analyzer cargo platform-info 2.0.5 UNameAPI#}; |
| 7 | |
| 8 | fn mainrust-analyzer cargo platform-info 2.0.5 main().() { |
| 9 | let info = PlatformInforust-analyzer cargo platform-info 2.0.5 lib_impl/target/PlatformInfo#::newrust-analyzer cargo platform-info 2.0.5 lib_impl/target/impl#[PlatformInfo][PlatformInfoAPI]new().().expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Unable to determine platform info"); |
| 10 | // println!("info={:#?}", info); // note: info *may* contain extra platform-specific fields |
| 11 | |
| 12 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{}", info.sysnamerust-analyzer cargo platform-info 2.0.5 lib_impl/target/impl#[PlatformInfo][UNameAPI]sysname().().to_string_lossyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsStr]to_string_lossy().()); |
| 13 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{}", info.nodenamerust-analyzer cargo platform-info 2.0.5 lib_impl/target/impl#[PlatformInfo][UNameAPI]nodename().().to_string_lossyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsStr]to_string_lossy().()); |
| 14 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{}", info.releaserust-analyzer cargo platform-info 2.0.5 lib_impl/target/impl#[PlatformInfo][UNameAPI]release().().to_string_lossyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsStr]to_string_lossy().()); |
| 15 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{}", info.versionrust-analyzer cargo platform-info 2.0.5 lib_impl/target/impl#[PlatformInfo][UNameAPI]version().().to_string_lossyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsStr]to_string_lossy().()); |
| 16 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{}", info.machinerust-analyzer cargo platform-info 2.0.5 lib_impl/target/impl#[PlatformInfo][UNameAPI]machine().().to_string_lossyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsStr]to_string_lossy().()); |
| 17 | printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("{}", info.osnamerust-analyzer cargo platform-info 2.0.5 lib_impl/target/impl#[PlatformInfo][UNameAPI]osname().().to_string_lossyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/impl#[OsStr]to_string_lossy().()); |
| 18 | } |