
M03 Mutability
Rust mutability guide mapping E0596, E0499, and E0502 errors to Cell, RefCell, Mutex, and RwLock choices.
- skills.sh installs
- 3.7K
- GitHub stars
- 1.6K
- last updated
- Aug 21, 2026
Own this skill? Claim it
What it does
- Covers borrow-rule errors E0596, E0499, and E0502, with a design question to ask before adding mutability
- Includes a trace-up path to m09-domain and m07-concurrency when borrow conflicts or lock issues persist
- Provides a decision table choosing among
Cell<T>,RefCell<T>,Mutex<T>,RwLock<T>, andAtomic*by Copy-ness and thread context - Designed for Rust developers resolving borrow checker errors who need to pick interior mutability correctly
Install
$ npx -y skills add actionbook/rust-skills --skill m03-mutability -yInstalls into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.
Files
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 |
|---|---|---|
| E0596 | "Add mut" | Should this really be mutable? |
| E0499 | "Split borrows" | Is the data structure right? |
| E0502 | "Separate scopes" | Why do we need both borrows? |
| RefCell panic | "Use try_borrow" | Is runtime check appropriate? |
Thinking Prompt
Before adding mutability:
-
Is mutation necessary?
- Maybe transform → return new value
- Maybe builder → construct immutably
-
Who controls mutation?
- External caller →
&mut T - Internal logic → interior mutability
- Concurrent access → synchronized mutability
- External caller →
-
What's the thread context?
- Single-thread → Cell/RefCell
- Multi-thread → Mutex/RwLock/Atomic
Trace Up ↑
When mutability conflicts persist:
Details
- Repository
- github.com/actionbook/rust-skills
- Categories
- Rust, Debugging
- First seen
- May 16, 2026
More from actionbook/rust-skills
All 38- M12 Lifecycle3.6K
- M09 Domain3.6K
- M14 Mental Model3.6K
- M13 Domain Error3.6K
- M11 Ecosystem3.6K
- Unsafe Checker3.6K
- Rust Code Navigator3.6K
- Rust Trait Explorer3.5K
- Rust Call Graph3.5K
- Rust Symbol Analyzer3.5K
- Domain Web3.5K
- Domain Cli3.5K
- Rust Learner3.4K
- Rust Skill Creator3.4K
- Rust Deps Visualizer3.3K
- Meta Cognition Parallel3.3K
- Rust Daily3.3K
- Domain Embedded3.2K
- Domain Cloud Native3.2K
- Domain Fintech3.1K
- Domain Ml3.1K
- Domain Iot3K
- Rust Router3K
- Core Agent Browser2.3K
Similar to M03 Mutability
More Rust
m01-ownershipactionbook/rust-skills3.7K installsRust ownership and lifetime error guide that maps compiler codes to design questions before quick fixes.
m02-resourceactionbook/rust-skills3.7K installsChoosing Rust smart pointers by ownership model, thread context, and reference cycles, with a decision flowchart.
rust-systems-programmingmanutej/luxor-claude-marketplace489 installsComplete Rust guide covering ownership, borrowing, concurrency, async, and unsafe code for memory-safe systems work.
rust-unsafemohitmishra786/low-level-dev-skills646 installsGuide to writing, reviewing, and auditing unsafe Rust, covering raw pointers, transmute, and sound abstractions.