rust-syntax-borrowing

Installation
SKILL.md

rust-syntax-borrowing

Mechanics of &T / &mut T, Non-Lexical Lifetimes, two-phase borrows, reborrowing, split borrows, and interior mutability. The borrow checker is not your enemy: most errors point to a real soundness issue that .clone() would only paper over.

Cross-references: [[rust-syntax-ownership]] (move semantics is the alternative to borrowing), [[rust-syntax-lifetimes]] (lifetime annotations on borrows), [[rust-errors-borrow-checker]] (E-code-specific decoding), [[rust-core-memory-model]] (conceptual overview).


When to use this skill

  • User writes code that fails with E0502 ("cannot borrow x as mutable because it is also borrowed as immutable"), E0499 ("cannot borrow x as mutable more than once at a time"), or E0596 ("cannot borrow x as mutable, as it is not declared as mutable").
  • User asks "can I have a & and &mut at the same time".
  • User reaches for .clone() to silence the borrow checker.
  • User asks "what is RefCell / Cell / interior mutability".
  • User wants to mutate two fields of a struct from two threads / two closures / two scopes.
  • User asks "how do I get two mutable references into different parts of a Vec".
  • User asks "what is reborrowing" or "why does my &mut get passed but the original keeps working".

Installs
2
GitHub Stars
1
First Seen
May 24, 2026