version_check

Function supports_feature

Source
pub fn supports_feature(feature: &str) -> Option<bool>
Expand description

Checks whether the running or installed rustc supports feature.

Please see the note on feature detection.

Returns true iff is_feature_flaggable() returns true and the feature is not disabled via exclusion in allow-features via RUSTFLAGS or CARGO_ENCODED_RUSTFLAGS. If the version could not be determined, returns None.

ยงExample

use version_check as rustc;

if let Some(true) = rustc::supports_feature("doc_cfg") {
   println!("cargo:rustc-cfg=has_doc_cfg");
}