install
source · Clone the upstream repo
git clone https://github.com/ComeOnOliver/skillshub
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ComeOnOliver/skillshub "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/pproenca/dot-skills/rust" ~/.claude/skills/comeonoliver-skillshub-rust && rm -rf "$T"
manifest:
skills/pproenca/dot-skills/rust/SKILL.mdsource content
Community Rust Best Practices
Comprehensive performance optimization guide for Rust applications. Contains 42 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
- Optimizing memory allocation and ownership patterns
- Working with iterators and collections
- Writing async code with Tokio or other runtimes
- Reviewing code for performance issues
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Memory Allocation | CRITICAL | |
| 2 | Ownership & Borrowing | CRITICAL | |
| 3 | Data Structure Selection | HIGH | |
| 4 | Iterator & Collection Patterns | HIGH | |
| 5 | Async & Concurrency | MEDIUM-HIGH | |
| 6 | Algorithm Complexity | MEDIUM | |
| 7 | Compile-Time Optimization | MEDIUM | |
| 8 | Micro-optimizations | LOW | |
Quick Reference
1. Memory Allocation (CRITICAL)
- Avoid unnecessary clone callsmem-avoid-unnecessary-clone
- Preallocate Vec capacitymem-preallocate-vec-capacity
- Use Cow for conditional ownershipmem-use-cow-for-conditional-ownership
- Use Arc for shared immutable datamem-use-arc-for-shared-immutable-data
- Avoid format! for simple concatenationmem-avoid-format-for-simple-concatenation
- Use SmallVec for small collectionsmem-use-smallvec-for-small-collections
2. Ownership & Borrowing (CRITICAL)
- Accept &str instead of &Stringown-accept-str-slice-not-string
- Accept &[T] instead of &Vec<T>own-accept-slice-not-vec
- Use Into<T> for flexible ownershipown-use-into-for-flexible-ownership
- Return borrowed data when possibleown-return-borrowed-when-possible
- Use AsRef<T> for generic borrowsown-use-asref-for-generic-borrows
3. Data Structure Selection (HIGH)
- Use HashSet for membership testsds-use-hashset-for-membership
- Use HashMap for key-value lookupsds-use-hashmap-for-key-lookup
- Use BTreeMap for sorted iterationds-use-btreemap-for-sorted-iteration
- Use VecDeque for queue operationsds-use-vecdeque-for-queue-operations
- Use Entry API for conditional insertds-use-entry-api-for-conditional-insert
4. Iterator & Collection Patterns (HIGH)
- Chain iterators instead of intermediate collectiter-chain-instead-of-intermediate-collect
- Use iter() over into_iter() when borrowingiter-use-iter-over-into-iter-when-borrowing
- Use filter_map for combined operationsiter-use-filter-map-for-combined-operations
- Use flat_map for nested iterationiter-use-flat-map-for-nested-iteration
- Use extend() for bulk appenditer-use-extend-for-bulk-append
- Use fold() for complex accumulationiter-use-fold-for-accumulation
5. Async & Concurrency (MEDIUM-HIGH)
- Avoid blocking in async contextasync-avoid-blocking-in-async-context
- Use join! for concurrent futuresasync-use-join-for-concurrent-futures
- Use RwLock over Mutex for read-heavyasync-use-rwlock-over-mutex-for-read-heavy
- Minimize lock scopeasync-minimize-lock-scope
- Use buffered() for bounded concurrencyasync-use-buffered-for-bounded-concurrency
- Avoid holding lock across awaitasync-avoid-holding-lock-across-await
6. Algorithm Complexity (MEDIUM)
- Avoid nested loops for lookupsalgo-avoid-nested-loops-for-lookup
- Use binary search for sorted dataalgo-use-binary-search-for-sorted-data
- Use sort_unstable when order irrelevantalgo-use-sort-unstable-when-order-irrelevant
- Use select_nth_unstable for partial sortalgo-use-select-nth-unstable-for-partial-sort
- Use chunks() for batch processingalgo-use-chunks-for-batch-processing
7. Compile-Time Optimization (MEDIUM)
- Use const for compile-time computationcomp-use-const-for-compile-time-computation
- Prefer static dispatch over dynamiccomp-prefer-static-dispatch
- Reduce monomorphization bloatcomp-reduce-monomorphization-bloat
- Use const generics for array sizescomp-use-const-generics-for-array-sizes
- Avoid repeated parsing of static datacomp-avoid-repeated-parsing-of-static-data
8. Micro-optimizations (LOW)
- Apply inline attribute to small hot functionsmicro-use-inline-for-small-functions
- Avoid bounds checks in hot loopsmicro-avoid-bounds-checks-in-hot-loops
- Use wrapping arithmetic when safemicro-use-wrapping-arithmetic-when-safe
- Use byte literals for ASCIImicro-use-byte-literals-for-ascii
How to Use
Read individual reference files for detailed explanations and code examples:
- Section definitions - Category structure and impact levels
- Rule template - Template for adding new rules
Full Compiled Document
For a comprehensive guide with all rules in a single document, see AGENTS.md.
Reference Files
| File | Description |
|---|---|
| AGENTS.md | Complete compiled guide with all rules |
| references/_sections.md | Category definitions and ordering |
| assets/templates/_template.md | Template for new rules |
| metadata.json | Version and reference information |