Only include cargo.toml dependency on nightly?


I’ve got a no-std project that has a dependency on lazy_static. Unfortunately, lazy_static can only be no-std on nightly right now. I’ve made it so that my code only uses it on nightly, but even though I don’t include it via extern crate lazy_static; on stable, I still get a compilation error because its inclusion as a Cargo.toml dependency causes it to be compiled. Is there a way that I can instruct cargo not to try to compile it if I’m not compiling on nightly?


Many crates have a “nightly” feature to obtain this behavior.



Ah that works; thanks!