{}
RustCanon
Learn
Patterns
78+
Runnable Rust patterns by topic
Software Engineering
Classic patterns adapted for Rust
Anti-Patterns
Common pitfalls and how to avoid them
Compiler Errors
Decode the most common error messages
Build
Recipes
80+
Real-world project templates with crates
Learning Paths
Structured journeys from beginner to expert
Practice
Exams
Practice tests and skill assessments
Reference
Cheatsheet
Quick reference for syntax and idioms
Resources
Curated books, courses, and tools
Home
Patterns
78+
Software Engineering
Anti-Patterns
Compiler Errors
Recipes
80+
Learning Paths
Exams
Cheatsheet
Resources
{}
Rust Anti-patterns
Tempting on the surface, wrong underneath — a what-not-to-do catalog with canonical alternatives.
Arc<Mutex<Vec<T>>> as default shared state
Using a global mutex-guarded vector when message passing would do.
concurrency
performance
deadlock
Arc<RwLock<T>> as the default shared-state container
Reaching for Arc<RwLock<T>> for read-mostly state when arc-swap or atomics fit.
concurrency
performance
contention
Arc when scoped threads would do
Wrapping borrowable data in Arc just to spawn a thread.
concurrency
threading
ownership
block_on inside an async fn
Calling Runtime::block_on or futures::executor::block_on from already-async code.
async
runtime
deadlock
Blocking call inside async
std::thread::sleep or sync I/O inside an async fn.
async
runtime
performance
Boxing values that fit comfortably on the stack
Box<T> reached for as a default container instead of by need.
memory
allocation
performance
Box<dyn Fn> as the default closure type
Heap-allocating every closure when a generic parameter would inline.
performance
closures
monomorphization
Clone-cascade
Sprinkling .clone() across the call site to silence the borrow checker.
performance
ownership
allocation
Collect-then-iter round trip
Materializing an iterator into Vec just to iterate it again.
iteration
performance
allocation
dyn Trait where impl Trait or generics fit
Reaching for Box<dyn Trait> by reflex when a static-dispatched parameter would do.
generics
traits
dispatch
Error from format string
Box<dyn Error>::from(format!("...")) instead of a typed error.
error-handling
library-design
format! in a hot loop
Allocating a fresh String per iteration to build messages that get discarded or appended.
performance
allocation
formatting
Load more
(12 / 30)