<skill_overview> Write idiomatic, readable, and maintainable Rust
Writing new Rust code Reviewing naming and style Refactoring for idiomatic patterns Setting formatting and lint rules
Rust API Guidelines rustfmt Clippy
</skill_overview> <naming_conventions> Functions, variables, modules, files Types, traits, enums, enum variants Constants, static items Use as_* for cheap conversions Use to_* for potentially expensive conversions </naming_conventions>
Always run cargo fmt before commit Prefer trailing commas to reduce diff noise Avoid manual alignment; let rustfmt decide
<ownership_and_borrowing>
Prefer borrowing over cloning Take &str or &[T] for read-only inputs Use iterators instead of index-based loops Return owned values when caller should own data
fn find_user(name: &str, users: &[User]) -> Option<&User> { /* ... */ }
</ownership_and_borrowing> <pattern_matching>
Use exhaustive match for enums Avoid catch-all _ unless truly unreachable Use if let / while let for single-variant matches
</pattern_matching> <anti_patterns> Avoid unwrap/expect in non-test code Do not clone to silence borrow checker Avoid large mutable shared state </anti_patterns>