Skip to content

Probe for Rust language features from build.rs

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

tov/feature-probe-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

feature-probe-rs: probe for Rust language features from build.rs

Build Status Crates.io License: MIT License: Apache 2.0

To support multiple versions of Rust, it's often necessary to conditionally compile parts of our libraries or programs. It's possible to allow users to specify what features to enable, but detection is better, because users get all the features that their version of Rust supports. And while we could check the rustc version, it's better to probe for individual features.

Usage

It’s on crates.io, so you can add

[build-dependencies]
feature-probe = "0.1.1"

Then add to your build.rs:

extern crate feature_probe;

use feature_probe::Probe;

Then you can probe for features such as types or expressions. For example:

fn main () {
    let probe = Probe::new();
    
    if probe.probe_type("i128") {
        println!("cargo:rustc-cfg=int_128");
    }
    
    if probe.probe_type("::std::ops::RangeInclusive<u64>") {
        println!("cargo:rustc-cfg=inclusive_range");
    }
}

This crate supports Rust version 1.16.0 and later.

About

Probe for Rust language features from build.rs

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Languages