Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
bighardperson avatar

Rust

  • 8 installs
  • 33 repo stars
  • Updated April 26, 2026
  • bighardperson/computer-science-skills-collection

rust is a Claude skill that helps write idiomatic Rust and avoid ownership, borrow-checker, lifetime, and concurrency pitfalls.

About

This skill helps write idiomatic Rust by naming the common ownership, borrowing, lifetime, and concurrency pitfalls and their fixes. A developer uses it when writing or debugging Rust and fighting the borrow checker or confusing compiler errors. It maps traps to reference files and offers a compiler-error lookup table.

  • Reference for writing idiomatic Rust and avoiding ownership, borrow-checker, and lifetime traps
  • Tables of high-frequency failures across ownership, strings, errors, iterators, concurrency, and memory
  • Includes a common-compiler-errors table and Cargo traps

Rust by the numbers

  • 8 all-time installs (skills.sh)
  • Ranked #88 of 121 Rust skills by installs in the Skillselion catalog
  • Data as of Jul 30, 2026 (Skillselion catalog sync)
At a glance

Rust capabilities & compatibility

Free; needs local rustc and cargo, no API key

Capabilities
debugging · refactoring
Use cases
debugging · refactoring
Platforms
Linux · macOS · Windows
Pricing
Free
From the docs

What Rust says it does

Write idiomatic Rust avoiding ownership pitfalls, lifetime confusion, and common borrow checker battles.
SKILL.md
**`s[0]` doesn't compile** — use `.chars().nth(0)` or `.bytes()`
SKILL.md
**`Rc` is NOT `Send`** — use `Arc` for threads
SKILL.md
npx skills add https://github.com/bighardperson/computer-science-skills-collection --skill rust

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs8
repo stars33
Last updatedApril 26, 2026
Repositorybighardperson/computer-science-skills-collection

What it does

Write idiomatic Rust and resolve ownership, borrow-checker, lifetime, and concurrency pitfalls.

When should I use this skill?

Writing or debugging Rust and fighting the borrow checker, lifetimes, or confusing compiler errors.

By the numbers

  • 6-row common compiler errors table
  • 5 reference files (ownership-borrowing, types-strings, errors-iteration, concurrency-memory, advanced-traps)

Files

SKILL.mdMarkdownGitHub ↗

Quick Reference

TopicFileKey Trap
Ownership & Borrowingownership-borrowing.mdMove semantics catch everyone
Strings & Typestypes-strings.mdString vs &str, UTF-8 indexing
Errors & Iterationerrors-iteration.mdunwrap() in production, lazy iterators
Concurrency & Memoryconcurrency-memory.mdRc not Send, RefCell panics
Advanced Trapsadvanced-traps.mdunsafe, macros, FFI, performance

---

Critical Traps (High-Frequency Failures)

Ownership — #1 Source of Compiler Errors

  • Variable moved after use — clone explicitly or borrow with &
  • `for item in vec` moves vec — use &vec or .iter() to borrow
  • `String` moved into function — pass &str for read-only access

Borrowing — The Borrow Checker Always Wins

  • Can't have `&mut` and `&` simultaneously — restructure or interior mutability
  • Returning reference to local fails — return owned value instead
  • Mutable borrow through `&mut self` blocks all access — split struct or RefCell

Lifetimes — When Compiler Can't Infer

  • `'static` means CAN live forever, not DOESString is 'static capable
  • Struct with reference needs `<'a>`struct Foo<'a> { bar: &'a str }
  • Function returning ref must tie to inputfn get<'a>(s: &'a str) -> &'a str

Strings — UTF-8 Surprises

  • `s[0]` doesn't compile — use .chars().nth(0) or .bytes()
  • `.len()` returns bytes, not chars — use .chars().count()
  • `s1 + &s2` moves s1 — use format!("{}{}", s1, s2) to keep both

Error Handling — Production Code

  • `unwrap()` panics — use ? or match in production
  • `?` needs `Result`/`Option` return type — main needs -> Result<()>
  • `expect("context")` > `unwrap()` — shows why it panicked

Iterators — Lazy Evaluation

  • `.iter()` borrows, `.into_iter()` moves — choose carefully
  • `.collect()` needs typecollect::<Vec<_>>() or typed binding
  • Iterators are lazy — nothing runs until consumed

Concurrency — Thread Safety

  • `Rc` is NOT `Send` — use Arc for threads
  • `Mutex` lock returns guard — auto-unlocks on drop, don't hold across await
  • `RwLock` deadlock — reader upgrading to writer blocks forever

Memory — Smart Pointers

  • `RefCell` panics at runtime — if borrow rules violated
  • `Box` for recursive types — compiler needs known size
  • Avoid `Rc<RefCell<T>>` spaghetti — rethink ownership

---

Common Compiler Errors (NEW)

ErrorCauseFix
value moved hereUsed after moveClone or borrow
cannot borrow as mutableAlready borrowedRestructure or RefCell
missing lifetime specifierAmbiguous referenceAdd <'a>
the trait bound X is not satisfiedMissing implCheck trait bounds
type annotations neededCan't inferTurbofish or explicit type
cannot move out of borrowed contentDeref movesClone or pattern match

---

Cargo Traps (NEW)

  • `cargo update` updates Cargo.lock, not Cargo.toml — manual version bump needed
  • Features are additive — can't disable a feature a dependency enables
  • `[dev-dependencies]` not in release binary — but in tests/examples
  • `cargo build --release` much faster — debug builds are slow intentionally

Related skills

FAQ

Why does String indexing like s[0] not compile in Rust?

Because String is UTF-8; use .chars().nth(0) or .bytes() instead.

When should I use Arc instead of Rc?

Rc is NOT Send, so use Arc for sharing across threads.

Rustbackend

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.