← ClaudeAtlas

rust-patternslisted

Idiomatic Rust patterns, ownership, error handling, traits, concurrency, and best practices for building safe, performant applications.
tincopper/neeko · ★ 11 · AI & Automation · score 77
Install: claude install-skill tincopper/neeko
# Rust Development Patterns Idiomatic Rust patterns and best practices for building safe, performant, and maintainable applications. ## When to Use - Writing new Rust code - Reviewing Rust code - Refactoring existing Rust code - Designing crate structure and module layout ## How It Works This skill enforces idiomatic Rust conventions across six key areas: ownership and borrowing to prevent data races at compile time, `Result`/`?` error propagation with `thiserror` for libraries and `anyhow` for applications, enums and exhaustive pattern matching to make illegal states unrepresentable, traits and generics for zero-cost abstraction, safe concurrency via `Arc<Mutex<T>>`, channels, and async/await, and minimal `pub` surfaces organized by domain. ## Core Principles ### 1. Ownership and Borrowing Rust's ownership system prevents data races and memory bugs at compile time. ```rust // Good: Pass references when you don't need ownership fn process(data: &[u8]) -> usize { data.len() } // Good: Take ownership only when you need to store or consume fn store(data: Vec<u8>) -> Record { Record { payload: data } } // Bad: Cloning unnecessarily to avoid borrow checker fn process_bad(data: &Vec<u8>) -> usize { let cloned = data.clone(); // Wasteful — just borrow cloned.len() } ``` ### Use `Cow` for Flexible Ownership ```rust use std::borrow::Cow; fn normalize(input: &str) -> Cow<'_, str> { if input.contains(' ') { Cow::Owned(input.replace(' ', "_"))