current_platform 0.2.0

Find out what platform your code is running on
Documentation
  • Coverage
  • 100%
    3 out of 3 items documented1 out of 1 items with examples
  • Size
  • Source code size: 17.53 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 131.82 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Shnatsel/current_platform
    32 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • tarcieri Shnatsel

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).