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
View on GitHub

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>, and Atomic* 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 -y

Installs 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

ErrorDon't Just SayAsk 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:

  1. Is mutation necessary?

    • Maybe transform → return new value
    • Maybe builder → construct immutably
  2. Who controls mutation?

    • External caller → &mut T
    • Internal logic → interior mutability
    • Concurrent access → synchronized mutability
  3. 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

Similar to M03 Mutability

More Rust