rust-patterns

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

3|Updated Mar 17, 2026
One-click install
npx skills add https://github.com/idiaz01/enterprise-superpowers --skill rust-patterns-idiaz01
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust-patterns
Source: https://github.com/idiaz01/enterprise-superpowers/tree/main/content/skills/rust-patterns
Command: npx skills add https://github.com/idiaz01/enterprise-superpowers --skill rust-patterns-idiaz01

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Rust's ownership model, error handling, and concurrency conventions can lead to bugs and maintenance pain when patterns are not followed. This Skill codifies idiomatic Rust practices to help developers write safer, more maintainable code with clear abstractions.

Core Features & Use Cases

  • Ownership and borrowing best practices to prevent data races at compile time
  • Error propagation using thiserror for libraries and anyhow for applications
  • Exhaustive enums and pattern matching to model valid states
  • Traits and generics for zero-cost abstractions and flexible APIs
  • Safe concurrency with Arc<Mutex<T>>, channels, and async patterns
  • Guidance for unsafe code usage and crate/module organization

Quick Start

Apply idiomatic Rust patterns to improve safety, performance, and maintainability in your codebase.

Frequently Asked Questions about rust-patterns

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

FAQPage Schema
What's the best way to handle error propagation in Rust libraries versus applications?

Error propagation in Rust libraries should use thiserror for structured custom errors, while applications should use anyhow for flexible context-based error handling to maintain clear abstractions and maintainability.

How do I share data safely across threads in Rust?

Share data safely across threads in Rust by using Arc<Mutex<T>> to provide atomic reference counting and mutual exclusion, or use channels to pass messages and prevent data races at compile time.

How do I use enums and pattern matching to model valid states in Rust?

Use exhaustive enums and pattern matching to model valid states in Rust, ensuring the compiler forces you to handle all possible variations, which prevents invalid state bugs and improves code safety.

When should I use unsafe code in Rust?

Use unsafe code in Rust only when you need to interface with hardware or optimize beyond safe Rust capabilities, following strict guidelines to ensure the encapsulated operations do not violate ownership or borrowing rules.

How do I use traits and generics for zero-cost abstractions in Rust?

Use traits and generics to create zero-cost abstractions in Rust, allowing flexible, polymorphic APIs without runtime overhead by ensuring type safety and monomorphization are handled at compile time.

What are the common ownership and borrowing issues in Rust and how do I fix them?

Common ownership and borrowing issues in Rust cause data races and compile-time errors, which you fix by applying idiomatic patterns like proper lifetime annotations and structuring data to prevent simultaneous mutable access.