rust-patterns
Idiomatic Rust patterns, ownership, error handling, traits, concurrency, and best practices for building safe, performant applications.
npx skills add mturac/everything-openai-codex --skill rust-patterns --agent codex
Same command for any agent — swap --agent for claude-code, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# 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>)
- When to Use
- How It Works
- Core Principles
- 1. Ownership and Borrowing
- Use Cow for Flexible Ownership
- Error Handling
- Use Result and ? — Never unwrap() in Production
- Library Errors with thiserror, Application Errors with anyhow
- Option Combinators Over Nested Matching
- Enums and Pattern Matching
- Model States as Enums
- Exhaustive Matching — No Catch-All for Business Logic
- Traits and Generics
- Accept Generics, Return Concrete Types
Build and check cargo build cargo check # Fast type checking without codegen cargo clippy # Lints and suggestions cargo fmt # Format code Testing cargo test cargo test -- --nocapture # Show println output cargo test --lib # Unit tests only cargo test --test integration # Integration tests only
What does the rust-patterns skill do?
Idiomatic Rust patterns, ownership, error handling, traits, concurrency, and best practices for building safe, performant applications.
How do I install it?
Run `npx skills add mturac/everything-openai-codex --skill rust-patterns --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From mturac/everything-openai-codex, a repository with 84 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
