返回 Skill 列表
extension
分类: 开发与工程无需 API Key

rust-idioms

来自Rust社区的重构和惯用模式指南(前身为rust-refactor)。在编写、审查或重构Rust代码时,应使用此技能以确保遵循惯用模式和保持清晰的架构。当任务涉及Rust类型、所有权、错误处理、特征、模块、转换或迭代器模式时触发。

person作者: jakexiaohubgithub

Rust Community Rust Refactoring Best Practices

Comprehensive refactoring and idiomatic patterns guide for Rust applications, maintained by the Rust Community. Contains 44 rules across 8 categories, prioritized by impact to guide automated refactoring and code generation.

When to Apply

Reference these guidelines when:

  • Writing new Rust code with strong type guarantees
  • Refactoring ownership and borrowing patterns
  • Designing error handling strategies
  • Creating public APIs with traits and generics
  • Organizing modules and controlling visibility

Rule Categories by Priority

| Priority | Category | Impact | Prefix | |----------|----------|--------|--------| | 1 | Type Safety & Newtype Patterns | CRITICAL | type- | | 2 | Ownership & Borrowing | CRITICAL | own- | | 3 | Error Handling Patterns | HIGH | err- | | 4 | API Design & Traits | HIGH | api- | | 5 | Module & Visibility | MEDIUM-HIGH | mod- | | 6 | Conversion Traits | MEDIUM | conv- | | 7 | Idiomatic Patterns | MEDIUM | idiom- | | 8 | Iterator & Collections | LOW-MEDIUM | iter- |

Quick Reference

1. Type Safety & Newtype Patterns (CRITICAL)

2. Ownership & Borrowing (CRITICAL)

3. Error Handling Patterns (HIGH)

4. API Design & Traits (HIGH)

5. Module & Visibility (MEDIUM-HIGH)

6. Conversion Traits (MEDIUM)

7. Idiomatic Patterns (MEDIUM)

8. Iterator & Collections (LOW-MEDIUM)

How to Use

Read individual reference files for detailed explanations and code examples:

Full Compiled Document

For a single-file comprehensive guide, see AGENTS.md.