Originally published on php2rust.dev — part of the PHP to Rust course. View this lesson on the original site.

Cargo works with different Rust toolchains: stable, beta, and nightly. The default is Stable Rust, which is updated every six weeks and is recommended for almost all projects, including learning and production.

Stable, Production-ready, backwards-compatible releases. Like PHP’s stable releases: predictable, well-tested, and safe for real applications.

Beta, Pre-release builds that become the next stable. Used for testing before a release; most learners never need it.

Nightly, Bleeding-edge builds with experimental features. Includes language features and APIs that may later land in stable, or may change or be removed. Use it only when you need a specific unstable feature (e.g. certain async runtimes, procedural macros, or compiler plugins).

To use Nightly for a project:

rustup install nightly
rustup default nightly

To switch back to Stable:

rustup default stable

You can also use Nightly for just one project without changing the global default, add a rust-toolchain.toml file in the project root with channel = "nightly". Cargo will use Nightly for that project only.

Recommendation: Stick with Stable unless you have a clear reason to use Nightly. Most libraries and tutorials target Stable.

What's next

Next: Creating a new Rust project.

From PHP to Rust — Getting Started with Rust