Install
openclaw skills install rustWrite idiomatic Rust avoiding ownership pitfalls, lifetime confusion, and common borrow checker battles.
openclaw skills install rust| Topic | File | Key Trap |
|---|---|---|
| Ownership & Borrowing | ownership-borrowing.md | Move semantics catch everyone |
| Strings & Types | types-strings.md | String vs &str, UTF-8 indexing |
| Errors & Iteration | errors-iteration.md | unwrap() in production, lazy iterators |
| Concurrency & Memory | concurrency-memory.md | Rc not Send, RefCell panics |
| Advanced Traps | advanced-traps.md | unsafe, macros, FFI, performance |
&for item in vec moves vec — use &vec or .iter() to borrowString moved into function — pass &str for read-only access&mut and & simultaneously — restructure or interior mutability&mut self blocks all access — split struct or RefCell'static means CAN live forever, not DOES — String is 'static capable<'a> — struct Foo<'a> { bar: &'a str }fn get<'a>(s: &'a str) -> &'a strs[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 bothunwrap() panics — use ? or match in production? needs Result/Option return type — main needs -> Result<()>expect("context") > unwrap() — shows why it panicked.iter() borrows, .into_iter() moves — choose carefully.collect() needs type — collect::<Vec<_>>() or typed bindingRc is NOT Send — use Arc for threadsMutex lock returns guard — auto-unlocks on drop, don't hold across awaitRwLock deadlock — reader upgrading to writer blocks foreverRefCell panics at runtime — if borrow rules violatedBox for recursive types — compiler needs known sizeRc<RefCell<T>> spaghetti — rethink ownership| Error | Cause | Fix |
|---|---|---|
value moved here | Used after move | Clone or borrow |
cannot borrow as mutable | Already borrowed | Restructure or RefCell |
missing lifetime specifier | Ambiguous reference | Add <'a> |
the trait bound X is not satisfied | Missing impl | Check trait bounds |
type annotations needed | Can't infer | Turbofish or explicit type |
cannot move out of borrowed content | Deref moves | Clone or pattern match |
cargo update updates Cargo.lock, not Cargo.toml — manual version bump needed[dev-dependencies] not in release binary — but in tests/examplescargo build --release much faster — debug builds are slow intentionally