rust-type-driven
Solution Patterns
Pattern 1: Newtype Pattern
// ❌ Primitive types can be confused
fn process_user(id: u64) { ... }
fn process_order(id: u64) { ... }
// Easy to mix up:
process_order(user_id); // Compiles but wrong!
// ✅ Type-safe newtypes
struct UserId(u64);
struct OrderId(u64);
fn process_user(id: UserId) { ... }
fn process_order(id: OrderId) { ... }
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-anti-pattern
Rust anti-patterns and common mistakes expert. Handles code review issues with clone abuse, unwrap in production, String misuse, index loops, and refactoring guidance.
14rust-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-auth
Authentication and authorization expert covering JWT, API keys, OAuth, RBAC, password hashing, distributed token storage, and session management patterns.
12