runtime_environment
A Rust library to check the operating system at runtime.
Installation
In your Cargo.toml
, add the following line under the [dependencies]
section:
runtime_environment = "0.1.0"
Usage
This is an example usage someone might do:
use runtime_environment::{is_mac_os, is_windows, is_linux};
fn main() {
if is_mac_os() {
println!("Running on macOS");
} else if is_windows() {
println!("Running on Windows");
} else if is_linux() {
println!("Running on Linux");
} else {
println!("Running on an unknown OS");
}
}
Functions
is_mac_os() -> bool
Returns true if the operating system is macOS.
is_windows() -> bool
Returns true if the operating system is Windows.
is_linux() -> bool
Returns true if the operating system is Linux.
Testing
To run the tests, use…