Configure Code Based on Compiler Support

RecipeCratesCategories
Use sccachesccachecat-development-tools::build-utils

autocfg

autocfg autocfg-crates.io autocfg-github autocfg-lib.rs cat-development-tools::build-utils

Automatic cfg for Rust compiler features

A Rust library for build scripts to automatically configure code based on compiler support. Code snippets are dynamically tested to see if the rustc will accept them, rather than hard-coding specific version support.

Add to your Cargo.toml:

[build-dependencies]
autocfg = "1.0.0" # Or latest version
fn main() {
    let ac = autocfg::new();
    ac.emit_has_type("i128");

    // (optional) We don't need to rerun for anything external.
    autocfg::rerun_path("build.rs");
}