rust-pro
Installation
SKILL.md
Rust Professional Development
Goal: Write idiomatic, high-performance, and memory-safe Rust code following standard community practices (The Rust Way).
1. Core Principles
- Ownership & Borrowing: strictly enforce ownership rules. Avoid
.clone()unless necessary. UseArc<Mutex<T>>orRwLock<T>for shared state only when message passing (mpsc) is not viable. - Error Handling: Use
Result<T, E>withthiserrorfor libraries andanyhowfor applications. Never use.unwrap()in production code; use.expect()with a context message or?operator. - Async Runtime: Default to
tokiofor general purpose apps. Usejoin_allfor parallel execution of futures. - Type System: Leverage traits and generics for zero-cost abstractions. Use
New Typepattern to enforce validation at compile time.
2. Toolchain & Ecosystem
- Build System:
cargo - Linter:
clippy(Treat warnings as errors in CI) - Formatter:
rustfmt - Testing: Built-in
#[test]andcargo test. Usemockallfor mocking traits.