Back to Home
Tutorials · Rust

Rust Examples

Two guides that take you from no compiler to a working Rust program you wrote yourself, and then rewrote properly. Install the toolchain with rustup, learn the language one runnable example at a time (including the part everyone finds hard: ownership and borrowing), then build a bowling scorer twice. Every example on these pages was compiled and run, and its real output is shown.

The route these guides follow
⬇
Install
rustup · rustc
📦
Cargo
cargo new · run
✎
Basics
types · match
🔑
Ownership
move · borrow
🎳
Build
bowling · 167
Guides 2
START HERE

A compiler, and the basics.

LESSONS

Learn the language by building something.

The same bowling lesson as the Go, Python and C versions, so if you've done one of those you already know the problem and can concentrate on the Rust.

Why Rust feels strict

The compiler checks who owns every value and who is allowed to change it. Code that would crash or corrupt memory at run time in other languages simply doesn't compile. The error messages are long, but they usually tell you the exact fix.

cargo new, cargo run, cargo build --release. Everything on this page starts with those three commands.