huiali/rust-skills/rust-coding
Claude Code and agent skill by huiali/rust-skills
Trust tier 3
- community
Source check pending
Checking that the SKILL.md file is still in the repository.
Rust coding conventions expert covering naming, formatting, comments, clippy, rustfmt, lints, code style, best practices, and idiomatic patterns.
Install
npx vskill@latest install huiali/rust-skills/rust-codingSKILL.md
Naming Conventions (Rust-Specific)
| Rule | Correct | Incorrect | |
|---|---|---|---|
No get_ prefix for methods | fn name(&self) | fn get_name(&self) | |
| Iterator methods | iter() / iter_mut() / into_iter() | get_iter() | |
| Conversion naming | as_ (cheap), to_ (expensive), into_ (ownership) | Mixed usage | |
static variables uppercase | static CONFIG: Config | static config: Config | |
const variables | const BUFFER_SIZE: usize = 1024 | No restriction |
General Naming
Solution Patterns
Pattern 1: Conversion Methods
Pattern 2: Newtype Pattern
Pattern 3: Error Handling
Pattern 4: String Handling
Data Type Guidelines
| Rule | Description | Example | |
|---|---|---|---|
| Use newtype | Domain semantics | struct Email(String) | |
| Use slice patterns | Pattern matching | if let [first, .., last] = slice | |
| Pre-allocate | Avoid reallocations | Vec::with_capacity() | |
| Avoid Vec abuse | Fixed size → array | let arr: [u8; 256] |
String Guidelines
| Rule | Description | |
|---|---|---|
ASCII data use bytes() | s.bytes() faster than s.chars() | |
Might modify → Cow<str> | Borrow or owned | |
Use format! for concat | Better than + operator | |
Avoid nested contains() | O(n*m) complexity |
Error Handling Guidelines
| Rule | Description | |
|---|---|---|
Use ? to propagate | Don't use try!() macro | |
expect() over unwrap() | When value guaranteed | |
Use assert! for invariants | At function entry |
Memory and Lifetimes
| Rule | Description | |
|---|---|---|
| Meaningful lifetime names | 'src, 'ctx not just 'a | |
RefCell use try_borrow | Avoid panics | |
| Use shadowing for conversions | let x = x.parse()? |
Concurrency Guidelines
| Rule | Description | |
|---|---|---|
| Define lock ordering | Prevent deadlocks | |
| Atomics for primitives | Not Mutex<bool> | |
| Choose memory ordering carefully | Relaxed/Acquire/Release/SeqCst |
Async Guidelines
| Rule | Description | |
|---|---|---|
| CPU-bound → sync | Async for I/O | |
| Don't hold locks across await | Use scoped guards |
Macro Guidelines
| Rule | Description | |
|---|---|---|
| Avoid macros (unless necessary) | Prefer functions/generics | |
| Macro input like Rust | Readability first |
Deprecated Patterns → Modern
| Deprecated | Modern | Version | |
|---|---|---|---|
lazy_static! | std::sync::OnceLock | 1.70 | |
once_cell::Lazy | std::sync::LazyLock | 1.80 | |
std::sync::mpsc | crossbeam::channel | - | |
std::sync::Mutex | parking_lot::Mutex | - | |
failure/error-chain | thiserror/anyhow | - | |
try!() | ? operator | 2018 |
Clippy Configuration
Common Clippy Lints
| Lint | Description | |
|---|---|---|
clippy::all | Enable all warnings | |
clippy::pedantic | Stricter checks | |
clippy::unwrap_used | Avoid unwrap | |
clippy::expect_used | Prefer expect | |
clippy::clone_on_ref_ptr | Avoid cloning Arc |
Formatting (rustfmt)
Documentation Guidelines
Workflow
Step 1: Name Things Properly
Step 2: Format Code
Step 3: Review Idioms
Quick Reference
Review Checklist
When reviewing code:
- [ ] Naming follows Rust conventions
- [ ] Using
?instead ofunwrap() - [ ] Avoiding unnecessary
clone() - [ ]
unsafeblocks have SAFETY comments - [ ] Public APIs have doc comments
- [ ] Ran
cargo clippy - [ ] Ran
cargo fmt - [ ] No
get_prefix on accessor methods - [ ] Conversion methods named correctly (as/to/into)
- [ ] String parameters use
&strwhen possible
Verification Commands
Common Pitfalls
1. Wrong Method Naming
Symptom: Clippy warning wrong_self_convention
2. String Type Misuse
Symptom: Unnecessary allocations
3. Index Loops
Symptom: Less idiomatic, error-prone
Related Skills
- rust-anti-pattern - What not to do
- rust-error - Error handling patterns
- rust-performance - Performance idioms
- rust-async - Async conventions
- rust-unsafe - SAFETY comment style
Localized Reference
- Chinese version: SKILL_ZH.md - 完整中文版本,包含所有内容
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/rust-coding/SKILL.md
Popularity
- Repository stars
- 20
- Repository forks
- 4
- 7-day trend score
- 15
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 22 Mar 2026, 7 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/huiali/rust-skills/rust-coding)