Rust

Learn Rust by compiling it: cargo, ownership and borrowing, lifetimes, structs, enums and traits, Result and the ? operator, iterators, fearless concurrency with Send and Sync, and testing with clippy and rustfmt, with real compiler output from Rust 1.99.

Start course →

What you'll learn

  • Set up Rust projects with cargo and write programs using variables, expressions and pattern matching.
  • Explain ownership, moves, borrowing and lifetimes, and fix the compiler errors they produce.
  • Model data with structs, enums, Option, traits and generics.
  • Handle errors with Result, the ? operator and custom error types, and know when panics happen.
  • Use collections, iterators and closures, and write safe concurrent code with threads, Arc, Mutex and channels.
  • Test, lint and format Rust code with cargo test, clippy and rustfmt.

Syllabus

Getting Started With Rust

  1. Why Rust
  2. Hello, World and cargo
  3. Crates, Cargo.toml and Modules

Language Basics

  1. Variables, Mutability, Shadowing and Types
  2. Expressions and Pattern Matching
  3. Functions and Modules

Ownership, Borrowing and Lifetimes

  1. Ownership and Moves
  2. Borrowing With References
  3. The Aliasing Rule
  4. Lifetimes

Structs, Enums and Traits

  1. Structs and impl Blocks
  2. Enums, Option and Pattern Matching
  3. Traits and Generics

Error Handling

  1. Result and the ? Operator
  2. Custom Error Types
  3. Panics, unwrap and Safe Alternatives

Collections, Iterators and Strings

  1. Vec, HashMap and String
  2. Iterators and Closures
  3. String Slices and Array Slices

Fearless Concurrency

  1. Threads, Arc, Mutex and Channels
  2. Send and Sync: Data Races at Compile Time
  3. Async Rust at a Glance

Testing, Tooling and a Checklist

  1. Unit Tests With cargo test
  2. clippy and rustfmt
  3. A Rust Code Review Checklist