Installation & Cargo in Rust

From the Rust cheat sheet ยท Getting Started ยท verified Jul 2026

Installation & Cargo

Install Rust with rustup and use Cargo to create and run projects.

rust
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# Create a new project
cargo new my_project
cd my_project

# Build and run
cargo run

# Hello World โ€” src/main.rs
fn main() {
    println!("Hello, world!");
}
๐Ÿ’ก Use "cargo check" instead of "cargo build" for fast type-checking during development
โšก cargo clippy catches common mistakes and suggests idiomatic improvements
๐Ÿ“Œ println! uses {} for Display, {:?} for Debug, and {:#?} for pretty-printed Debug
๐ŸŸข Add dependencies to Cargo.toml โ€” Cargo downloads and compiles them automatically
installcargosetup
Back to the full Rust cheat sheet