rust-lifetimes-borrowing
Installation
SKILL.md
Rust Lifetimes & Borrowing
Comprehensive guide to Rust's ownership system, borrowing rules, and lifetime annotations based on The Rust Programming Language, The Rust Reference, and Common Rust Lifetime Misconceptions.
When to Use This Skill
- Borrow checker errors you don't understand
- Deciding between owned types and references
- Annotating lifetime parameters on structs/functions
- Understanding
'static,'a, and elision rules - Working with self-referential structures
- Debugging "does not live long enough" or "borrowed value dropped" errors
Ownership Rules
- Each value has exactly one owner.
- When the owner goes out of scope, the value is dropped.
- Ownership can be transferred (moved) but not duplicated (unless
Copy).