rust-expert-best-practices-code-review by wispbit-ai/skills
npx skills add https://github.com/wispbit-ai/skills --skill rust-expert-best-practices-code-review简洁、实用、有主见。只关注编写生产级 Rust 代码的关键要点。
在以下场景中参考这些指南:
| 优先级 | 类别 | 影响 | 前缀 |
|---|---|---|---|
| 1 | 类型安全 | 关键 | use-typesafe-, use-enum- |
| 2 | 错误处理 | 关键-高 | result-, avoid-panic |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 3 | API 设计 | 高 | use-borrowed-, prefer-builder- |
| 4 | 代码质量 | 中-高 | use-iterator-, prefer-format |
| 5 | 可读性 | 中 | use-named-, avoid-boolean- |
| 6 | 性能 | 中 | avoid-rc, avoid-box |
use-borrowed-argument-types - 使用 &str, &[T], &Path 而非 &String, &Vec, &PathBufuse-enum-deserialization - 使用穷举枚举匹配进行安全的反序列化use-typesafe-index-wrappers - 包装索引类型以防止混合不同的索引result-error-returns - 在返回 Result 的函数中使用 ? 运算符而非 unwrap/expectavoid-panic - 根据上下文使用 assert!、Result 或 expect 而非 panic!use-iterator-transforms - 使用迭代器方法而非显式的 push 循环use-copied - 使用 .copied() 以避免复杂的解引用模式prefer-format - 使用 format! 而非手动字符串拼接prefer-builder-pattern-for-complex - 对于拥有 4 个及以上参数的函数使用构建器模式use-named-placeholders - 在解构时使用命名占位符而非裸的 _decimal-comparison - 使用 .is_sign_negative() 而非与 Decimal::ZERO 比较calculated-field-as-method - 将计算字段实现为方法而非结构体字段avoid-rc - 在更简单的所有权模式可行时避免不必要的 Rcavoid-box - 没有正当理由时不要对具体类型使用 Boxavoid-boolean-params - 用枚举或结构体替换布尔参数match-statements-handle-all-cases - 显式处理所有枚举变体,避免使用通配模式阅读单独的规则文件以获取详细解释和代码示例:
rules/use-borrowed-argument-types.md
rules/use-enum-deserialization.md
rules/use-typesafe-index-wrappers.md
rules/result-error-returns.md
rules/avoid-panic.md
rules/use-iterator-transforms.md
rules/use-copied.md
rules/prefer-format.md
rules/prefer-builder-pattern-for-complex.md
rules/use-named-placeholders.md
rules/decimal-comparison.md
rules/calculated-field-as-method.md
rules/avoid-rc.md
rules/avoid-box.md
rules/avoid-boolean-params.md
rules/match-statements-handle-all-cases.md
每个规则文件包含:
每周安装次数
123
代码仓库
GitHub 星标数
5
首次出现
2026 年 2 月 11 日
安全审计
安装于
cursor115
opencode65
gemini-cli62
codex61
github-copilot61
kimi-cli59
Simple, pragmatic, opinionated. Only what matters for writing production-grade Rust code.
Reference these guidelines when:
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Type Safety | CRITICAL | use-typesafe-, use-enum- |
| 2 | Error Handling | CRITICAL-HIGH | result-, avoid-panic |
| 3 | API Design | HIGH | use-borrowed-, prefer-builder- |
| 4 | Code Quality | MEDIUM-HIGH | use-iterator-, prefer-format |
| 5 | Readability | MEDIUM | use-named-, avoid-boolean- |
| 6 | Performance | MEDIUM | avoid-rc, avoid-box |
use-borrowed-argument-types - Use &str, &[T], &Path instead of &String, &Vec, &PathBufuse-enum-deserialization - Use exhaustive enum matching for safe deserializationuse-typesafe-index-wrappers - Wrap index types to prevent mixing different indicesresult-error-returns - Use ? operator instead of unwrap/expect in Result functionsavoid-panic - Use assert!, Result, or expect based on context instead of panic!use-iterator-transforms - Use iterator methods instead of explicit push loopsuse-copied - Use .copied() to avoid complex dereferencing patternsprefer-format - Use format! over manual string concatenationRead individual rule files for detailed explanations and code examples:
rules/use-borrowed-argument-types.md
rules/use-enum-deserialization.md
rules/use-typesafe-index-wrappers.md
rules/result-error-returns.md
rules/avoid-panic.md
rules/use-iterator-transforms.md
rules/use-copied.md
rules/prefer-format.md
rules/prefer-builder-pattern-for-complex.md
rules/use-named-placeholders.md
rules/decimal-comparison.md
rules/calculated-field-as-method.md
rules/avoid-rc.md
rules/avoid-box.md
rules/avoid-boolean-params.md
rules/match-statements-handle-all-cases.md
Each rule file contains:
Weekly Installs
123
Repository
GitHub Stars
5
First Seen
Feb 11, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
cursor115
opencode65
gemini-cli62
codex61
github-copilot61
kimi-cli59
代码安全审查清单:最佳实践与漏洞防范指南(含密钥管理、SQL注入防护)
1,700 周安装
Groove Work Plan:AI辅助代码库分析与项目计划生成工具 | 自动化开发流程
119 周安装
Groove Git日志自动化工具 - 自动生成每日Git提交摘要和变更记录
119 周安装
自媒体自动发布工具 - 支持百家号、知乎、公众号等平台一键发布,提升内容分发效率
105 周安装
Outlook自动化指南:通过Rube MCP与Composio工具包实现邮件、日历、联系人管理
83 周安装
WhoDB数据库助手:简化数据库操作,支持SQL查询、模式探索与数据导出
93 周安装
Xcode MCP 设置指南:连接 Claude、Cursor、VS Code 等 AI 助手到 Xcode 开发环境
101 周安装
prefer-builder-pattern-for-complexuse-named-placeholders - Use named placeholders instead of bare _ in destructuringdecimal-comparison - Use .is_sign_negative() instead of comparing to Decimal::ZEROcalculated-field-as-method - Implement calculated fields as methods not struct fieldsavoid-rc - Avoid unnecessary Rc when simpler ownership patterns workavoid-box - Don't use Box for concrete types without legitimate reasonavoid-boolean-params - Replace boolean parameters with enums or structsmatch-statements-handle-all-cases - Explicitly handle all enum variants without catch-all patterns