Rust

Write idiomatic Rust avoiding ownership pitfalls, lifetime confusion, and common borrow checker battles.

MIT-0 · Free to use, modify, and redistribute. No attribution required.
4 · 1.4k · 13 current installs · 13 all-time installs
byIván@ivangdavila
MIT-0
Security Scan
VirusTotalVirusTotal
Benign
View report →
OpenClawOpenClaw
Benign
high confidence
Purpose & Capability
Name/description (Rust guidance) align with requirements: it declares rustc and cargo as required binaries, which is appropriate for a Rust authoring helper.
Instruction Scope
SKILL.md and the included docs are purely educational guidance about ownership, lifetimes, errors, concurrency, etc.; they do not instruct the agent to read unrelated files, exfiltrate data, call external endpoints, or perform privileged system changes.
Install Mechanism
No install spec and no code files to execute are present. Being instruction-only minimizes the risk of downloading or running arbitrary code.
Credentials
The skill requests no environment variables, credentials, or config paths — nothing disproportionate to the stated purpose.
Persistence & Privilege
always is false and the skill does not request permanent or elevated privileges. Autonomous invocation is allowed by default on the platform but there are no additional privilege escalations requested by the skill.
Assessment
This skill is an instruction-only Rust reference and appears internally consistent. If you install it, ensure that the agent runs in an environment where rustc and cargo are legitimate system binaries you trust (the skill declares those as required). Because it can be invoked by the agent, be aware the agent might use local rust tooling when generating or checking code — if you run agents in a restricted environment, keep those restrictions in place. No credentials, downloads, or external endpoints are requested by this skill.

Like a lobster shell, security has layers — review code before you run it.

Current versionv1.0.1
Download zip
latestvk97c5c5cwzm5fn804c9h63qq6n815sg6

License

MIT-0
Free to use, modify, and redistribute. No attribution required.

Runtime requirements

🦀 Clawdis
OSLinux · macOS · Windows
Binsrustc, cargo

SKILL.md

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

Files

6 total
Select a file
Select a file to preview.

Comments

Loading comments…