m03-mutability

Installation
Summary

Rust mutability design: choosing between &mut, interior mutability, and thread-safe patterns.

  • Guides decision-making for E0596, E0499, E0502 errors by asking whether mutation is necessary and who controls it, rather than reflexively adding mut
  • Covers single-thread patterns (Cell, RefCell) and multi-thread patterns (Mutex, RwLock, Atomic types) with clear selection criteria
  • Includes borrow rule reference, anti-patterns (RefCell overuse, Mutex in hot loops), and decision tables for interior mutability scenarios
  • Traces upward to data structure design (m09-domain) and concurrency concerns (m07-concurrency) when borrow conflicts persist
SKILL.md

Mutability

Layer 1: Language Mechanics

Core Question

Why does this data need to change, and who can change it?

Before adding interior mutability, understand:

  • Is mutation essential or accidental complexity?
  • Who should control mutation?
  • Is the mutation pattern safe?

Error → Design Question

Error Don't Just Say Ask Instead
Related skills

More from zhanghandong/rust-skills

Installs
692
GitHub Stars
1.1K
First Seen
Jan 20, 2026