maverick-rust-ownership
Installation
SKILL.md
Rust Ownership Skill
Ownership Rules
- Each value has exactly one owner
- When owner goes out of scope, value is dropped
- Values can be moved or borrowed
Borrowing Rules
- One mutable reference OR any number of immutable references
- References must always be valid
let s = String::from("hello");
let r1 = &s; // OK
let r2 = &s; // OK
let r3 = &mut s; // ERROR: can't borrow as mutable