Outline updated November 2026

Intermediate14 hours delivered over 2-4 daysLive, online or on-site

Request this course

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, or unsafe.
  • 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 unsafe code 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
  • Drop implementations
  • 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 objects
  • Rc<T> and Weak<T>
  • Arc<T> for threads
  • The cost of each pointer type

Interior Mutability

  • Cell<T> for Copy types
  • RefCell<T> and runtime borrow checks
  • Mutex<T> and RwLock<T>
  • OnceCell, OnceLock, and lazy initialization
  • Thread safety of each type

Self-Referential Structures

  • Why naive self-references fail
  • Pin and !Unpin types
  • Owner-borrower structs with self_cell
  • Vetting crates with RustSec and Miri
  • The ouroboros soundness advisory
  • Arenas and generational indices with slotmap
  • Separating owned data from borrowed views

Memory Safety Across Boundaries

  • Send, Sync, and 'static in 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 Box and hidden clones
  • Prompting for low-cost borrow fixes
  • Refactoring toward clear ownership

Private team training

Bring this course to your team

Tell us about your team and we will tailor this outline to your tools, stack, and schedule. Courses can also be combined into a longer program.

  1. Tell us what you needYour tools, stack, team size, and timeline.
  2. We send a proposalA course or program, an outline adjusted to your team, and possible dates.
  3. Your team trains liveOnline or on-site, with courseware for every student.

Prefer to talk? Call +1 434-509-6890 or email help@cloudcontraptions.com.

We reply within 1 business day.

Training partner?