Rust Bootstrap Course for C/C++ Programmers
Course Overview
- Course overview
- The case for Rust (from both C and C++ perspectives)
- Local installation
- Types, functions, control flow, pattern matching
- Modules, cargo
- Traits, generics
- Collections, error handling
- Closures, memory management, lifetimes, smart pointers
- Concurrency
- Unsafe Rust, including Foreign Function Interface (FFI)
no_stdand embedded Rust essentials for firmware teams- Case studies: real-world C++ to Rust translation patterns
- We'll not cover
asyncRust in this course — see the companion Async Rust Training for a full treatment of futures, executors,Pin, tokio, and production async patterns
Self-Study Guide
This material works both as an instructor-led course and for self-study. If you're working through it on your own, here's how to get the most out of it:
Pacing recommendations:
| Chapters | Topic | Suggested Time | Checkpoint |
|---|---|---|---|
| 1–4 | Setup, types, control flow | 1 day | You can write a CLI temperature converter |
| 5–7 | Data structures, ownership | 1–2 days | You can explain why let s2 = s1 invalidates s1 |
| 8–9 | Modules, error handling | 1 day | You can create a multi-file project that propagates errors with ? |
| 10–12 | Traits, generics, closures | 1–2 days | You can write a generic function with trait bounds |
| 13–14 | Concurrency, unsafe/FFI | 1 day | You can write a thread-safe counter with Arc<Mutex<T>> |
| 15–16 | Deep dives | At your own pace | Reference material — read when relevant |
| 17–19 | Best practices & reference | At your own pace | Consult as you write real code |
How to use the exercises:
- Every chapter has hands-on exercises marked with difficulty: 🟢 Starter, 🟡 Intermediate, 🔴 Challenge
- Always try the exercise before expanding the solution. Struggling with the borrow checker is part of learning — the compiler's error messages are your teacher
- If you're stuck for more than 15 minutes, expand the solution, study it, then close it and try again from scratch
- The Rust Playground lets you run code without a local install
When you hit a wall:
- Read the compiler error message carefully — Rust's errors are exceptionally helpful
- Re-read the relevant section; concepts like ownership (ch7) often click on the second pass
- The Rust standard library docs are excellent — search for any type or method
- For async patterns, see the companion Async Rust Training
Table of Contents
Part I — Foundations
1. Introduction and Motivation
- Speaker intro and general approach
- The case for Rust
- How does Rust address these issues?
- Other Rust USPs and features
- Quick Reference: Rust vs C/C++
- Why C Developers Need Rust
- Why C++ Developers Need Rust
2. Getting Started
- Enough talk already: Show me some code
- Rust Local installation
- Rust packages (crates)
- Example: cargo and crates
3. Basic Types and Variables
- Built-in Rust types
- Rust type specification and assignment
- Rust type specification and inference
- Rust variables and mutability
4. Control Flow
5. Data Structures and Collections
- Rust array type
- Rust tuples
- Rust references
- C++ References vs Rust References — Key Differences
- Rust slices
- Rust constants and statics
- Rust strings: String vs &str
- Rust structs
- Rust Vec<T>
- Rust HashMap
- Exercise: Vec and HashMap
6. Pattern Matching and Enums
7. Ownership and Memory Management
- Rust memory management
- Rust ownership, borrowing and lifetimes
- Rust move semantics
- Rust Clone
- Rust Copy trait
- Rust Drop trait
- Exercise: Move, Copy and Drop
- Rust lifetime and borrowing
- Rust lifetime annotations
- Exercise: Slice storage with lifetimes
- Lifetime Elision Rules Deep Dive
- Rust Box<T>
- Interior Mutability: Cell<T> and RefCell<T>
- Shared Ownership: Rc<T>
- Exercise: Shared ownership and interior mutability
8. Modules and Crates
- Rust crates and modules
- Exercise: Modules and functions
- Workspaces and crates (packages)
- Exercise: Using workspaces and package dependencies
- Using community crates from crates.io
- Crates dependencies and SemVer
- Exercise: Using the rand crate
- Cargo.toml and Cargo.lock
- Cargo test feature
- Other Cargo features
- Testing Patterns
9. Error Handling
- Connecting enums to Option and Result
- Rust Option type
- Rust Result type
- Exercise: log() function implementation with Option
- Rust error handling
- Exercise: error handling
- Error Handling Best Practices
10. Traits and Generics
- Rust traits
- C++ Operator Overloading → Rust std::ops Traits
- Exercise: Logger trait implementation
- When to use enum vs dyn Trait
- Exercise: Think Before You Translate
- Rust generics
- Exercise: Generics
- Combining Rust traits and generics
- Rust traits constraints in data types
- Exercise: Trait constraints and generics
- Rust type state pattern and generics
- Rust builder pattern
11. Type System Advanced Features
12. Functional Programming
- Rust closures
- Exercise: Closures and capturing
- Rust iterators
- Exercise: Rust iterators
- Iterator Power Tools Reference
13. Concurrency
14. Unsafe Rust and FFI
- Unsafe Rust
- Simple FFI example
- Complex FFI example
- Ensuring correctness of unsafe code
- Exercise: Writing a safe FFI wrapper
Part II — Deep Dives
15. no_std — Rust for Bare Metal
16. Case Studies: Real-World C++ to Rust Translation
- Case Study 1: Inheritance hierarchy → Enum dispatch
- Case Study 2: shared_ptr tree → Arena/index pattern
- Case Study 3: Framework communication → Lifetime borrowing
- Case Study 4: God object → Composable state
- Case Study 5: Trait objects — when they ARE right
Part III — Best Practices & Reference
17. Best Practices
- Rust Best Practices Summary
- Avoiding excessive clone()
- Avoiding unchecked indexing
- Collapsing assignment pyramids
- Capstone Exercise: Diagnostic Event Pipeline
- Logging and Tracing Ecosystem