rust-syntax-pattern-matching
Installation
SKILL.md
Contains Shell Commands
This skill contains shell command directives (!`command`) that may execute system commands. Review carefully before installing.
rust-syntax-pattern-matching
The mechanics of pattern matching in Rust: match, if let, let else, while let, if-let chains (edition 2024, stable in 1.88), destructuring of tuples / structs / enums / slices / references, ref and ref mut, or-patterns, guards, @ bindings, .. rest patterns, range patterns, and literal patterns.
Cross-references: [[rust-syntax-edition-2024]] (if-let chain edition-gating, if let temporary scope change) [[rust-syntax-ownership]] (move vs borrow in match arms, when ref matters)
When to use this skill
- User writes a
matchand gets E0004 ("non-exhaustive patterns") or wants to know which arms are missing - User asks "should I use
match,if let, orlet elsehere" - User wonders why their
if letchain is rejected (edition or version too old) - User destructures a tuple, struct, enum, slice, or reference and the compiler complains about moves
- User asks what
ref/ref mutdoes and when to reach for it - User wants or-patterns (
A | B), guards (if cond), or@bindings explained - User asks about
..rest patterns in structs or slices - User writes a range pattern (
1..=10) or asks about exclusive ranges in patterns (stable in 1.80) - User gets E0408 (variable not bound in all patterns) or E0409 (variable bound with different mode/type)