Installing rustup
The official way to install Rust is through rustup, a small command-line tool that manages Rust toolchains. On macOS and Linux you run `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh` and follow the prompts. On Windows you download the rustup-init.exe installer. Once installed you'll have three commands on your PATH: `rustc` (the compiler), `cargo` (the package manager and build tool), and `rustup` itself.
For deeper background, see the canonical Rust learning roadmap for the broader context behind this section.
Hello, world
Create a new directory and a file called `main.rs`. Inside, write `fn main() { println!("Hello, world!"); }`. Compile it with `rustc main.rs`, then run the resulting binary. You have just produced a stand-alone native executable from a single source file. For anything beyond a single file you'll use cargo instead.
Cargo: the build tool
Run `cargo new hello` to scaffold a project. Cargo creates a `Cargo.toml` manifest, a `src/main.rs`, and a git repository. `cargo run` compiles and runs your project, `cargo build` produces a debug binary in `target/debug`, and `cargo build --release` produces an optimised binary in `target/release`.
Editions and toolchains
Rust ships in editions (2015, 2018, 2021, 2024) which let the language evolve without breaking existing code. Your `Cargo.toml` declares which edition the crate uses. rustup also lets you switch between stable, beta, and nightly toolchains with `rustup default stable`.