Rust Ownership
Ownership, borrowing, and lifetime expert. Handles compiler errors E0382, E0597, E0506, E0507, E0515, E0716, E0106 and provides systematic solutions for memory safety patterns.
Install
npx skills add huiali/rust-skills --skill rust-ownershipgit clone --depth 1 https://github.com/huiali/rust-skills.git /tmp/rust-skills
mkdir -p ~/.claude/skills
cp -r /tmp/rust-skills/.codex/skills/rust-ownership ~/.claude/skills/rust-ownershipPersonal skills live in ~/.claude/skills. Use .claude/skills in a project folder to share a skill with your team.
From the SKILL.md
## Solution Patterns
### Pattern 1: Value Moved After Use
```rust
let s1 = String::from("hello");
let s2 = s1;
// println!("{}", s1); // Compile error!
```
**Root Cause**: Ownership transferred from `s1` to `s2`, `s1` is no longer valid.
**Solutions**:
- Need two copies → use `clone()`
- Only need to read → pass by reference `&s1`
- `s2` is temporary → consider redesign
### Pattern 2: Borrow Conflict
```rust
let mut s = String::from("hello");
let r1 = &s;
let r2 = &mut s; // Conflict!
// println!("{}", r1);
```
**Root Cause**: Immutable and mutable borrows coexist.
**Solutions**:
- Ensure mutable borrow completes before creating new borrows
- Restructure code organization
### Pattern 3: Lifetime Mismatch
```rust
fn longest<'a>(s1: &'a str, s2: &'a str) -> &'a str {
if s1.len() > s2.len() { s1 } else { s2 }
}
```
**Root Cause**: Return value lifetime must be tied to one of the inputs.
**Key Solutions**:
1. Clarify each reference's lifetime
2. Use named lifetimes to express relationships
3. Prefer returning owned types
## Workflow
### Step 1: Who Owns the Data?
| Situation | Owner |
|-----------|-------|
| Function parameter | Caller owns |
| Function-local variable | Function owns (destroyed on return) |
| Struct field | Struct instance owns |
| `Arc<T>` | Multiple shared owners |
### Step 2: Is Borrowing Appropriate?
| Operation | Borrow Type | Notes |
|-----------|-------------|-------|
| Read-only | `&T` | Multiple can coexist |Details
- Skill name
rust-ownership- Repository
- huiali/rust-skills
- Path
.codex/skills/rust-ownership/SKILL.md- License
- MIT
- Repo updated
- 9 February 2026
FAQ
What does the Rust Ownership skill do?
Ownership, borrowing, and lifetime expert. Handles compiler errors E0382, E0597, E0506, E0507, E0515, E0716, E0106 and provides systematic solutions for memory safety patterns.
How do I install the Rust Ownership skill?
skills CLI (Claude Code, Cursor, Codex and more): npx skills add huiali/rust-skills --skill rust-ownership. Skills go in ~/.claude/skills (personal) or .claude/skills (project), and Claude loads them automatically when a task matches the description.
Is Rust Ownership popular?
It lives in huiali/rust-skills, which has 49 GitHub stars and 7 forks.
Related skills
Rust Actor
49huiali/rust-skills
Actor model expert covering message passing, state isolation, supervision trees, deadlock prevention, fault tolerance, Actix framework, and Erlang-style concurrency patterns.
Rust Anti Pattern
49huiali/rust-skills
Rust anti-patterns and common mistakes expert. Handles code review issues with clone abuse, unwrap in production, String misuse, index loops, and refactoring guidance.
Rust Async
49huiali/rust-skills
Advanced async patterns expert. Handles Stream processing, backpressure control, select/join operations, cancellation, Future trait implementation, and async runtime optimization.
Rust Performance
49huiali/rust-skills
Performance optimization expert covering profiling, benchmarking, memory allocation, SIMD, cache optimization, false sharing, lock contention, and NUMA-aware programming.
Rust Mutability
49huiali/rust-skills
Interior mutability expert covering Cell, RefCell, Mutex, RwLock patterns, borrow conflicts (E0596, E0499, E0502), and thread-safe mutation strategies.
Rust Pin
49huiali/rust-skills
Pin and self-referential types expert covering Pin, Unpin, Future, async state machines, pinning projection, and memory stability guarantees.
Browse the most popular Claude skills, all software development skills, or write your own with the skills generator.