How to using nightly crate in stable workspace

Hi There!

I have a project with three crates combined into a single workspace. For one of the crates, I need to use a random number generator, which is only included in the nightly version of the standard library. However, I don't want to change the version for the entire system. Is it possible to do this for just one crate?

I know about rust-toolchain(.toml), but when I created it in a local crate, cargo check at the workspace level still returned an error about features not being available for the stable compiler.

1 Like

Yes. Please don't do that. You'll need to play crazy and very unsupported tricks with the compiler to convince it that it bootstraps the compiler just for that one crate.

Yes, it's precisely how things are supposed to work. Protection is not 100% airtight and there are exist crazy ways to circumvent it with a build scripts, but I wouldn't try to build anything on top of that quicksand.

If you use nightly features then you have to use nightly compiler (or compiler teached to behave like nightly compiler with RUSTC_BOOTSTRAP set), period.

2 Likes

Yes, after a little thought, I came to the conclusion that this would probably cost me a lot, so I will just use rand crate from crates.io

1 Like