
M02 Resource
Choosing Rust smart pointers by ownership model, thread context, and reference cycles, with a decision flowchart.
- skills.sh installs
- 3.7K
- GitHub stars
- 1.6K
- last updated
- Aug 21, 2026
Own this skill? Claim it
What it does
- Covers the core pointers Box, Rc, Arc, Weak, Cell, and RefCell, plus Mutex and RwLock for shared mutable data
- Includes a decision flowchart, a quick-reference table, common errors with fixes, and anti-patterns to avoid
- Guides choices by asking whether ownership is single or shared, whether access is single-threaded, and whether cycles exist
- Designed for Rust developers deciding between Box and Rc, or Rc and Arc, and debugging leaks or RefCell panics
Install
$ npx -y skills add actionbook/rust-skills --skill m02-resource -yInstalls into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.
Files
Resource Management
Layer 1: Language Mechanics
Core Question
What ownership pattern does this resource need?
Before choosing a smart pointer, understand:
- Is ownership single or shared?
- Is access single-threaded or multi-threaded?
- Are there potential cycles?
Error → Design Question
| Error | Don't Just Say | Ask Instead |
|---|---|---|
| "Need heap allocation" | "Use Box" | Why can't this be on stack? |
| Rc memory leak | "Use Weak" | Is the cycle necessary in design? |
| RefCell panic | "Use try_borrow" | Is runtime check the right approach? |
| Arc overhead complaint | "Accept it" | Is multi-thread access actually needed? |
Thinking Prompt
Before choosing a smart pointer:
-
What's the ownership model?
- Single owner → Box or owned value
- Shared ownership → Rc/Arc
- Weak reference → Weak
-
What's the thread context?
- Single-thread → Rc, Cell, RefCell
- Multi-thread → Arc, Mutex, RwLock
-
Are there cycles?
- Yes → One direction must be Weak
- No → Regular Rc/Arc is fine
Trace Up ↑
When pointer choice is unclear, trace to design:
Details
- Repository
- github.com/actionbook/rust-skills
- Category
- Rust
- First seen
- May 16, 2026
More from actionbook/rust-skills
All 38- Rust Refactor Helper3.7K
- M03 Mutability3.7K
- 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
Similar to M02 Resource
More Rust
m03-mutabilityactionbook/rust-skills3.7K installsRust mutability guide mapping E0596, E0499, and E0502 errors to Cell, RefCell, Mutex, and RwLock choices.
m01-ownershipactionbook/rust-skills3.7K installsRust ownership and lifetime error guide that maps compiler codes to design questions before quick fixes.
memory-safety-patternswshobson/agents12.3K installsCross-language memory-safety patterns covering RAII, ownership, smart pointers, and resource management for Rust, C++, and C.
rust-systems-programmingmanutej/luxor-claude-marketplace489 installsComplete Rust guide covering ownership, borrowing, concurrency, async, and unsafe code for memory-safe systems work.