Skip to content

Rust Tutorial

This is a practical guide to Rust for people who are new to it. The lessons are short, every example is real code you can run, and I’ve tried to be honest about the parts that usually give beginners trouble.

Here’s a full Rust program. Click Try it Yourself to run it and change the message — it opens in the official Rust Playground, so there’s nothing to install.

fn main() {
println!("Hello, World!");
}
▶ Try it Yourself

Rust is used for the same kind of work as C and C++ — operating systems, browsers, game engines, databases, and command-line tools — anywhere speed and control matter. What’s different is that the Rust compiler catches a whole category of memory bugs before your program runs, and it does that without a garbage collector.

The catch is that Rust is stricter than most languages. It will reject code that other compilers happily accept. In return, you get programs that run fast and don’t fall over the way C programs often do.

That’s the reason it shows up in production at Cloudflare, Discord, and Dropbox, and why the Linux kernel now takes drivers written in Rust.

One honest heads-up: the first couple of weeks can be rough. Ownership and borrowing are genuinely new ideas, and arguing with the compiler is a bit of a rite of passage. It clicks sooner than you’d expect, and this guide is written to get you there with as little pain as possible.

If you’re starting from zero, work through the topics on the left roughly in order. If you already know some Rust, skip to whatever you need. Every code sample has a Try it Yourself button, so you can run it, break it, and see what happens as you read.

One tip worth knowing up front: read the compiler’s error messages. Rust’s are unusually good — they normally tell you what went wrong and how to fix it, so it pays to actually read them instead of skimming past.

  1. Rust Intro — what Rust is and why it exists
  2. Get Started — install it and run your first program
  3. Syntax — how a Rust program is put together
  4. Variables and Data Types — storing and typing data
  5. Functions — organizing your code
  6. Ownership and Borrowing — the parts that make Rust, Rust