Crates.io | os-ver |
lib.rs | os-ver |
version | 0.2.1 |
source | src |
created_at | 2024-05-16 17:59:53.657234 |
updated_at | 2024-10-21 08:36:45.822088 |
description | Detect version number of operating system (Windows, macOS, iOS, Linux) |
homepage | https://github.com/libark/os-ver-rs |
repository | https://github.com/libark/os-ver-rs |
max_upload_size | |
id | 1242340 |
size | 31,374 |
This library can be used to detect version number of operating system, such as Windows, macOS, iOS and Linux.
[dependencies]
os-ver = "0.2"
use os_ver::*;
#[cfg(target_os = "windows")]
if_greater_than!{windows::WIN11 => {
// Code for Windows 11 or newer
} else {
// Code for older versions
}};
#[cfg(target_os = "macos")]
if_greater_than!{macos::SONOMA => {
// Code for macOS Sonoma or newer
} else {
// Code for older versions
}};
if_greater_than!{(10, 0, 0, 1) => {
// Code for OS version >= 10.0.0.1
}};
let version = os_version();
// Print OS version
println!("OS version: {:?}", version);
#[cfg(target_os = "windows")]
if version >= &windows::WIN11 {
// Code for Windows 11 or newer
} else if version >= &windows::WIN10 {
// Code for Windows 10 or newer
} else if version >= &Version::new(10, 0, 0, 10586) {
// Code for Windows 10 TH2 or newer
}