#os-version #version #macos-ios #numbers #detect #win11

os-ver

Detect version number of operating system (Windows, macOS, iOS, Linux)

3 unstable releases

0.2.1 Oct 21, 2024
0.2.0 Oct 21, 2024
0.1.1 Jun 20, 2024
0.1.0 May 16, 2024

#258 in Operating systems

Download history 14/week @ 2024-09-16 7/week @ 2024-09-23 1/week @ 2024-09-30 295/week @ 2024-10-21 1/week @ 2024-10-28 4/week @ 2024-11-04 14/week @ 2024-11-11 17/week @ 2024-11-18 14/week @ 2024-11-25 15/week @ 2024-12-02 40/week @ 2024-12-09 24/week @ 2024-12-16

97 downloads per month
Used in 7 crates (5 directly)

MIT/Apache

12KB
202 lines

os-ver

Version Documentation License License

This library can be used to detect version number of operating system, such as Windows, macOS, iOS and Linux.

Example

[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
}

Dependencies

~0–5MB
~16K SLoC