rust-anti-pattern
✓Rust 反模式与常见错误。处理代码审查、clone、unwrap、String 用法、迭代器等问题。触发词:anti-pattern, common mistake, clone, unwrap, code review, 代码异味, 常见错误, 代码审查, refactor, 重构
Installation
SKILL.md
| 1 | 用 .clone() 躲避借用检查 | 使用引用 | | 2 | 生产代码用 .unwrap() | 用 ? 或 withcontext() | | 3 | 什么都是 String | 用 &str,必要时用 Cow | | 4 | 索引循环 | 用迭代器 .iter(), .enumerate() | | 5 | 与生命周期对抗 | 重新设计数据结构 |
| 很多 .clone() | 所有权不清晰 | 明确数据流 | | 很多 .unwrap() | 错误处理缺失 | 添加 Result 处理 | | 很多 pub 字段 | 封装被破坏 | 私有 + 访问器 | | 深度嵌套 | 逻辑复杂 | 提取方法 | | 函数过长 (>50行) | 职责过多 | 拆分职责 | | 巨大的枚举 | 缺少抽象 | Trait + 类型 |
| 索引循环 .items[i] | .iter().enumerate() | | collect:: >() 然后再遍历 | 链式迭代器 | | lazystatic! | std::sync::OnceLock | | mem::transmute 转换 | as 或 TryFrom | | 自定义链表 | Vec 或 VecDeque | | 手动 unsafe cell | Cell, RefCell |
Facts (cite-ready)
Stable fields and commands for AI/search citations.
- Install command
npx skills add https://github.com/huiali/rust-skills --skill rust-anti-pattern- Source
- huiali/rust-skills
- Category
- </>Dev Tools
- Verified
- ✓
- First Seen
- 2026-02-01
- Updated
- 2026-02-18
Quick answers
What is rust-anti-pattern?
Rust 反模式与常见错误。处理代码审查、clone、unwrap、String 用法、迭代器等问题。触发词:anti-pattern, common mistake, clone, unwrap, code review, 代码异味, 常见错误, 代码审查, refactor, 重构 Source: huiali/rust-skills.
How do I install rust-anti-pattern?
Open your terminal or command line tool (Terminal, iTerm, Windows Terminal, etc.) Copy and run this command: npx skills add https://github.com/huiali/rust-skills --skill rust-anti-pattern Once installed, the skill will be automatically configured in your AI coding environment and ready to use in Claude Code or Cursor
Where is the source repository?
https://github.com/huiali/rust-skills
Details
- Category
- </>Dev Tools
- Source
- skills.sh
- First Seen
- 2026-02-01