rust-anti-pattern
Top 5 Beginner Mistakes
| Rank | Mistake | Correct Approach |
|---|---|---|
| 1 | Using .clone() to escape borrow checker |
Use references |
| 2 | Using .unwrap() in production code |
Use ? or with_context() |
| 3 | Everything is String |
Use &str, Cow<str> when needed |
| 4 | Index-based loops | Use iterators .iter(), .enumerate() |
| 5 | Fighting lifetimes | Redesign data structure |
Common Anti-Patterns
Anti-Pattern 1: Clone Everywhere
// ❌ Bad: escaping borrow checker
fn process(user: User) {
More from huiali/rust-skills
rust-performance
Performance optimization expert covering profiling, benchmarking, memory allocation, SIMD, cache optimization, false sharing, lock contention, and NUMA-aware programming.
17rust-actor
Actor model expert covering message passing, state isolation, supervision trees, deadlock prevention, fault tolerance, Actix framework, and Erlang-style concurrency patterns.
13rust-ffi
FFI cross-language interop expert covering C/C++ bindings, bindgen, cbindgen, PyO3, JNI, memory layout, data conversion, and safe FFI patterns.
13rust-ecosystem
Rust ecosystem expert covering crate selection, library recommendations, framework comparisons, async runtime choices (tokio, async-std), and common tools.
13rust-type-driven
Type-driven design expert covering newtype pattern, type state, PhantomData, marker traits, builder pattern, compile-time validation, sealed traits, and zero-sized types (ZST).
13rust-auth
Authentication and authorization expert covering JWT, API keys, OAuth, RBAC, password hashing, distributed token storage, and session management patterns.
12