#compile-time #platform #find #fn #running #out

current_platform

Find out what platform your code is running on

3 unstable releases

Uses old Rust 2015

0.2.0 Apr 13, 2022
0.1.0 Mar 30, 2022

#963 in Development tools

Download history 591/week @ 2022-08-06 440/week @ 2022-08-13 475/week @ 2022-08-20 400/week @ 2022-08-27 227/week @ 2022-09-03 334/week @ 2022-09-10 679/week @ 2022-09-17 532/week @ 2022-09-24 700/week @ 2022-10-01 498/week @ 2022-10-08 874/week @ 2022-10-15 2830/week @ 2022-10-22 3076/week @ 2022-10-29 4028/week @ 2022-11-05 4049/week @ 2022-11-12 4024/week @ 2022-11-19

15,907 downloads per month
Used in 9 crates (7 directly)

MIT OR Apache-2.0 OR Zlib

7KB

current_platform

Find out what platform your code is running on, in Rust:

use current_platform::CURRENT_PLATFORM;

fn main() {
    println!("Running on {}", CURRENT_PLATFORM);
}

will print Running on x86_64-unknown-linux-gnu on desktop Linux.

Platform information is resolved at compile time, based on the platform for which your code is compiled. It incurs zero runtime cost.

The target triple for the platform where the code was compiled is also included as COMPILED_ON. It is only different from the CURRENT_PLATFORM if the code was cross-compiled. This is rarely useful; if in doubt, use CURRENT_PLATFORM.

This crate is intentionally minimal and only provides the target triples. You can find out other properties of the platform using crates such as platforms (auto-generated, always up to date) or target-lexicon (more detailed but may be missing newly added or obscure platforms).

No runtime deps