Closed CodeSandwich closed 4 years ago
I think you would need to add a build.rs script:
#[rustversion::nightly]
fn main() {
println!("cargo:rustc-cfg=unstable_feature");
}
#[rustversion::not(nightly)]
fn main() {}
and then do:
#![cfg_attr(unstable_feature, feature(unstable_feature))]
A bit nicer to read with rustversion::cfg!
macro now (which isn't directly mentioned in the readme)
fn main() {
if rustversion::cfg!(nightly) {
println!("cargo:rustc-cfg=unstable_feature");
}
}
I'd like to use an unstable feature only when crate is compiled with nightly. Is it possible to annotate the
#![feature(unstable_feature)]
line so it's visible only for nightly compiler?