← ClaudeAtlas

rust-standardslisted

Write idiomatic Rust code. Use when writing Rust code.
kimgoetzke/coding-agent-configs · ★ 2 · AI & Automation · score 75
Install: claude install-skill kimgoetzke/coding-agent-configs
## Testing - Unit tests in `#[cfg(test)]` modules within each source file - Integration tests in `tests/` directory ## Naming - No `get_` prefix: `fn name()` not `fn get_name()` - Iterator convention: `iter()` / `iter_mut()` / `into_iter()` - Conversion naming: `as_` (cheap &), `to_` (expensive), `into_` (ownership) - Static var prefix: `G_CONFIG` for `static`, no prefix for `const` ## Data Types - Use newtypes: `struct Email(String)` for domain semantics - Prefer slice patterns: `if let [first, .., last] = slice` - Pre-allocate: `Vec::with_capacity()`, `String::with_capacity()` - Avoid `Vec` abuse: use arrays for fixed sizes ## Strings - Prefer `&str` over `String` in function parameters - Use `String` for ownership: return `String` when transferring ownership - Prefer bytes: `s.bytes()` over `s.chars()` when ASCII - Use `Cow<str>` when you might need to modify borrowed data - Use `format!` over string concatenation with `+` - Avoid nested iteration: `contains()` on string is O(n\*m) ## Error Handling - Use `?` for all fallible operations - `unwrap()` in tests only, never production - `expect()` only for provably impossible states; the message must justify why it can't fail e.g. `expect("regex is valid: validated at compile time")` - `unwrap_or` / `unwrap_or_else` / `unwrap_or_default` for deliberate fallbacks - Assertions for invariants: `assert!` at function entry ## Memory - Meaningful lifetimes: `'src`, `'ctx` not just `'a` - `try_borrow()` for RefCell to avoi