rust-idiomatic-patterns

Provides Rust coding best practices covering ownership, error handling, and design patterns.

5|Updated Mar 12, 2026
One-click install
npx skills add https://github.com/JheisonMB/skills --skill rust-idiomatic-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rust-idiomatic-patterns
Source: https://github.com/JheisonMB/skills/tree/main/rust-idiomatic-patterns
Command: npx skills add https://github.com/JheisonMB/skills --skill rust-idiomatic-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill assists developers in writing clean, efficient, and secure Rust code by providing expert-level patterns and best practices.

Core Features & Use Cases

  • Ownership & Borrowing Guidance: Offers decision tables for ownership and borrowing scenarios.
  • Error Handling Best Practices: Suggests the use of thiserror for libraries and anyhow for binaries.
  • Iterative Patterns: Recommends avoiding intermediate collect() and using filter_map and find.
  • Structs & Enums: Provides advice on struct and enum design, including let...else and Box<T>.
  • Design Patterns: Implements the SOLID principles and DRY (Don't Repeat Yourself) philosophy.
  • Code Quality: Offers best practices for code quality, refactoring, and using Clippy.

Quick Start

Activate the skill when working on Rust code to get instant guidance on ownership, error handling, DRY principles, and more.

Frequently Asked Questions about rust-idiomatic-patterns

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

FAQPage Schema
What's the best way to handle ownership and borrowing when refactoring Rust code?

For Rust ownership and borrowing, use decision tables to evaluate scenarios, applying patterns like `Box<T>` for struct design and `let...else` for control flow to ensure efficient memory usage without intermediate allocations.

How do I choose error handling best practices for Rust libraries versus binaries?

Rust error handling best practices dictate using `thiserror` for libraries to define custom error types and `anyhow` for binaries to handle dynamic application errors, ensuring clean and secure code propagation.

How do I optimize Rust iterators to avoid unnecessary intermediate collections?

Optimize Rust iterators by avoiding intermediate `collect()` calls and instead chaining `filter_map` and `find` operations, which reduces memory allocation and improves loop efficiency during refactoring.

Do I need to understand Rust design patterns to apply SOLID principles effectively?

Applying SOLID principles in Rust requires understanding core design patterns and the DRY philosophy, enabling you to structure structs and enums correctly while leveraging Clippy for code quality validation.

Can I use this guidance for writing new Rust functions as well as refactoring existing code?

Yes, this Rust guidance targets all stages of code development, providing best practices for writing new functions with correct ownership and refactoring existing code to improve quality and security.