Beginner Fundamentals
Installation
The recommended way to install Rust is through rustup, the official toolchain installer. It manages the compiler, package manager, and updates for you.
Install with rustup
On macOS or Linux, run this in your terminal:
// Run in your shell, not in Rust code:
// curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
On Windows, download and run the installer from the official Rust website. After installation, restart your terminal.
Check the compiler
The Rust compiler is called rustc. Verify the install:
// rustc --version
// cargo --version
You can compile a single file directly:
// rustc main.rs
// ./main
Editions
Rust uses editions (like 2015, 2018, 2021) to introduce changes without breaking old code. A project declares its edition, so older code keeps compiling while you opt into newer features. Most new projects use the latest edition.
Updating
Keep your toolchain current with:
// rustup update