language-rust
Installation
SKILL.md
Rust
Ownership in one paragraph
Every value has one owner. Passing by value moves; borrow with & (shared, many) or &mut (exclusive, one). Shared and mutable references cannot coexist. Most "fights with the borrow checker" are a design smell — the data model mixed ownership and sharing.
Borrowing rules of thumb
&Twhen you only read.&mut Twhen you mutate in place.T(by value) when you consume — builders, transforming constructors.- Return owned types unless the caller clearly benefits from a borrow tied to a parameter's lifetime.
Lifetimes
- Start without annotations; add them when the compiler asks.
'staticdoes not mean "lives forever" — it means "no non-static references inside". Prefer owned types over'staticjuggling.- If a struct needs many lifetimes, consider owned data or
Arcinstead.