rust-patterns

Apply idiomatic Rust patterns for ownership, error handling, and concurrency.

86|21|Updated Feb 9, 2026
One-click install
npx skills add https://github.com/Jamkris/everything-gemini-code --skill rust-patterns-jamkris
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust-patterns
Source: https://github.com/Jamkris/everything-gemini-code/tree/main/skills/rust-patterns
Command: npx skills add https://github.com/Jamkris/everything-gemini-code --skill rust-patterns-jamkris

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Idiomatic Rust patterns, ownership, error handling, traits, concurrency, and best practices for building safe, performant applications. This guide helps teams adopt Rust conventions to prevent common pitfalls and to design robust, maintainable codebases.

Core Features & Use Cases

  • Ownership and borrowing to prevent data races at compile time.
  • Error handling with Result, thiserror, and anyhow for libraries and applications.
  • Enums and exhaustive pattern matching to model valid states.
  • Traits and generics for zero-cost abstractions and flexible APIs.
  • Safe concurrency patterns using Arc<Mutex<T>> and channels.
  • Module organization by domain to improve project structure.

Quick Start

Review a small Rust snippet and refactor it to follow ownership, error handling, and concurrency best practices.

Frequently Asked Questions about rust-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I handle errors idiomatically in Rust using Result, thiserror, and anyhow?

Idiomatic Rust error handling uses Result for explicit propagation, thiserror for custom library error enums, and anyhow for application-level error aggregation. This approach ensures robust, maintainable codebases by enforcing explicit error management at compile time.

What is the best way to implement safe concurrency in Rust?

Safe concurrency in Rust is best implemented using Arc<Mutex<T>> for shared state and channels for message passing. These patterns prevent data races at compile time through ownership and borrowing rules, ensuring thread safety without runtime overhead.

How do I use ownership and borrowing to prevent data races in Rust?

Ownership and borrowing prevent data races in Rust by enforcing strict compile-time rules over memory access. This Skill guides refactoring snippets to follow these rules, ensuring safe references and mutable borrows that eliminate concurrent modification bugs.

When should I use traits and generics for zero-cost abstractions in Rust?

Traits and generics provide zero-cost abstractions in Rust when designing flexible APIs and polymorphic behavior without runtime overhead. Use them to enforce shared functionality across types while maintaining compile-time monomorphization for peak performance.

Does this Rust patterns guide cover module organization by domain?

Yes, this Rust patterns guide covers module organization by domain to improve project structure. It helps teams adopt conventions for ownership, error handling, and concurrency best practices to design robust and maintainable codebases.

How do I refactor Rust code to use enums and exhaustive pattern matching?

Refactoring Rust code to use enums and exhaustive pattern matching models valid states explicitly. This Skill identifies and applies idiomatic patterns to review code, enforcing best practices that prevent invalid states and improve safety.