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