Outline updated November 2026
Memory-Safe Programming with Rust
Class Duration
14 hours of live training delivered over 2-4 days to accommodate your scheduling needs.
Student Prerequisites
- Prior Rust programming experience equivalent to Rust Essentials
- Comfort writing functions, structs, and enums
- Working understanding of how the stack and heap differ
Target Audience
Rust developers who can satisfy the borrow checker on simple code but struggle with threads, async tasks, or self-referential data. It also fits developers who accept AI-suggested Rc<RefCell<T>> or Arc<Mutex<T>> without knowing whether it is needed. New to Rust? Start with Rust Essentials or the longer Mastering Rust. Teams continuing on can move to Rust Parallel Programming.
Description
This course is for developers who know basic Rust but hit limits with lifetimes, self-referential structs, shared async state, or FFI. It works through Rust's memory model, smart pointers and their costs, and interior mutability. Students model self-referential data with Pin, the self_cell crate, or arenas and indices. They also check helper crates for soundness, since some popular self-referencing crates have had soundness bugs. Finally, students review AI-suggested Arc<Mutex<T>> code and learn when it hides a design problem.
Learning Outcomes
- Explain stack, heap, ownership, borrowing, and lifetimes precisely.
- Fix borrow-checker errors without reaching for
Rc,RefCell, orunsafe. - Choose the right smart pointer for each situation.
- Model self-referential data with
Pin,self_cell, or arenas. - Vet helper crates for soundness.
- Reason about ownership across threads and async tasks.
- Judge when AI-suggested
Arc<Mutex<T>>is the right fix. - Wrap necessary
unsafecode in a safe abstraction.
Training Materials
All students receive comprehensive courseware covering all topics in the course. Courseware is distributed via GitHub in the form of documentation and extensive code samples. Students practice the topics covered through challenging hands-on lab exercises.
Software Requirements
A free GitHub account, the current stable Rust toolchain via rustup (2024 edition), the nightly toolchain's Miri component for checking unsafe code, Visual Studio Code or another supported editor with the rust-analyzer extension, and an AI coding assistant of choice (GitHub Copilot, Cursor, or Claude Code) for the AI code review topics. A cloud-based environment can be provided if local installation is restricted.
Training Topics
How Memory Works
- How the OS sees process memory
- Stack vs. heap allocation
- Failure modes of manual memory management
- The costs of garbage collection
- Compile-time memory safety and its limits
Variables, Bindings, and Data
- Variables vs. their data
- Mutable bindings vs. mutable data
- Move, copy, and clone
Dropimplementations- Shadowing and scope
The Rust Memory Model
- Ownership, borrowing, and references
- Lifetime elision and annotations
- Higher-ranked bounds
- Shared XOR mutable
- Stack and heap data in Rust
- Working with the borrow checker
Reading Borrow-Checker Errors
- Common error patterns
- Changing data shape vs. adding indirection
- Spotting bad AI fixes
Smart Pointers
- What smart pointers are
Box<T>and trait objectsRc<T>andWeak<T>Arc<T>for threads- The cost of each pointer type
Interior Mutability
Cell<T>forCopytypesRefCell<T>and runtime borrow checksMutex<T>andRwLock<T>OnceCell,OnceLock, and lazy initialization- Thread safety of each type
Self-Referential Structures
- Why naive self-references fail
Pinand!Unpintypes- Owner-borrower structs with
self_cell - Vetting crates with RustSec and Miri
- The
ouroborossoundness advisory - Arenas and generational indices with
slotmap - Separating owned data from borrowed views
Memory Safety Across Boundaries
Send,Sync, and'staticin async code- Shared state in Tokio tasks
- Auditing FFI boundaries
- The rules of
unsafe - Finding undefined behavior with Miri
AI-Assisted Memory-Management Review
- Reflexive
Arc<Mutex<T>>from AI - Needless
Boxand hidden clones - Prompting for low-cost borrow fixes
- Refactoring toward clear ownership