All Patterns

Browse and filter 41 advanced Rust patterns

Filters

Showing 41 of 41 patterns

Split Borrowing
advanced
Borrow different parts of a struct simultaneously
🔐Ownership & Borrowing Patterns
borrowingmutabilitystructs
🎮 Playground
Interior Mutability Patterns
advanced
When to use Cell, RefCell, and Mutex
🔐Ownership & Borrowing Patterns
cellrefcellmutex
🎮 Playground
Self-Referential Structures
expert
Using Pin and safe patterns for self-references
🔐Ownership & Borrowing Patterns
pinunsafeadvanced
🎮 Playground
Lifetime Elision Mastery
advanced
Complex lifetime scenarios and elision rules
🔐Ownership & Borrowing Patterns
lifetimesreferences
🎮 Playground
RAII Guards
intermediate
Custom drop guards for resource management
🔐Ownership & Borrowing Patterns
dropresourcesraii
🎮 Playground
Rc/Arc Usage Patterns
intermediate
When to use each and cycle prevention
🎯Smart Pointers & Interior Mutability
rcarcreference-counting
🎮 Playground⚡ WASM
Weak Pointers
advanced
Breaking cycles in graph structures
🎯Smart Pointers & Interior Mutability
weakgraphscycles
🎮 Playground
Clone-on-Write (Cow)
intermediate
Zero-copy until mutation needed
🎯Smart Pointers & Interior Mutability
cowoptimizationcloning
🎮 Playground
Custom Smart Pointers
expert
Building your own Box-like types
🎯Smart Pointers & Interior Mutability
derefdropcustom
🎮 Playground
Custom Error Types
intermediate
Implementing std::error::Error properly
⚠️Error Handling Excellence
errorcustom-types
🎮 Playground
Error Composition
intermediate
Using thiserror and anyhow effectively
⚠️Error Handling Excellence
thiserroranyhowcomposition
🎮 Playground
Result Combinators
intermediate
and_then, or_else, map_err mastery
⚠️Error Handling Excellence
resultcombinatorsfunctional
🎮 Playground
Error Context
advanced
Maintaining error chains and context
⚠️Error Handling Excellence
contexterror-chains
🎮 Playground
Associated Types vs Generics
advanced
When to use which approach
🎨Advanced Trait System
traitsassociated-typesgenerics
🎮 Playground
Higher-Ranked Trait Bounds
expert
for<'a> patterns and HRTBs
🎨Advanced Trait System
hrtblifetimesadvanced
🎮 Playground
Trait Objects & Dynamic Dispatch
intermediate
Box<dyn Trait> patterns and vtables
🎨Advanced Trait System
dyndynamic-dispatchvtable
🎮 Playground
Blanket Implementations
advanced
Implementing traits for generic types
🎨Advanced Trait System
blanketimplgenerics
🎮 Playground
Orphan Rules & Newtype
intermediate
Working with external traits
🎨Advanced Trait System
orphan-rulesnewtypewrapper
🎮 Playground
Custom Future Implementation
expert
Building futures from scratch
Async/Await & Futures
futureasyncpoll
🎮 Playground
Stream Processing
advanced
Async iterators and backpressure
Async/Await & Futures
streamasync-iteratorbackpressure
🎮 Playground
Select/Join Patterns
intermediate
Concurrent future composition
Async/Await & Futures
selectjointokio
🎮 Playground
Cancellation & Timeouts
advanced
Proper cleanup patterns
Async/Await & Futures
cancellationtimeoutcleanup
🎮 Playground
Declarative Macros
intermediate
macro_rules! patterns and repetition
🔮Macro Mastery
macro_rulesdeclarative
🎮 Playground
Procedural Macros
expert
Derive, attribute, and function-like
🔮Macro Mastery
proc-macroderiveattribute
🎮 Playground
DSL Creation
expert
Domain-specific languages in Rust
🔮Macro Mastery
dslmacrosyntax
🎮 Playground
Iterator Composition
intermediate
How iterators optimize to machine code
🚀Zero-Cost Abstractions
iteratoroptimizationzero-cost
🎮 Playground
Monomorphization
advanced
Understanding generic compilation
🚀Zero-Cost Abstractions
genericscompilationoptimization
🎮 Playground
Const Evaluation
advanced
Compile-time computation
🚀Zero-Cost Abstractions
constcompile-timeconst-fn
🎮 Playground
State Machines in Types
advanced
Compile-time state validation
🎭Type-State Programming
typestatestate-machinetypes
🎮 Playground⚡ WASM
Builder with TypeState
advanced
Enforcing build order at compile time
🎭Type-State Programming
buildertypestateapi-design
🎮 Playground
Phantom Types
advanced
Zero-runtime-cost type information
🎭Type-State Programming
phantomzero-costmarker
🎮 Playground
Send/Sync Bounds
intermediate
Understanding thread safety
🔀Concurrency Patterns
sendsyncthread-safety
🎮 Playground
Channel Patterns
intermediate
mpsc, oneshot, broadcast patterns
🔀Concurrency Patterns
channelmpsccommunication
🎮 Playground
Lock-Free Data Structures
expert
Using atomics correctly
🔀Concurrency Patterns
atomiclock-freeconcurrent
🎮 Playground
Scoped Threads
advanced
Borrowing across thread boundaries
🔀Concurrency Patterns
scopethreadsborrowing
🎮 Playground
Safe Abstractions Over Unsafe
expert
Encapsulation patterns for unsafe code
Unsafe & FFI
unsafeencapsulationsafety
🎮 Playground
FFI Boundaries
advanced
C interop best practices
Unsafe & FFI
ffic-interopextern
🎮 Playground
Memory Layout
advanced
#[repr(C)] and layout guarantees
Unsafe & FFI
reprlayoutmemory
🎮 Playground
Memory Layout Optimization
advanced
Struct packing and alignment
Performance Optimization
memoryalignmentoptimization
🎮 Playground
SIMD Patterns
expert
Portable SIMD and platform-specific
Performance Optimization
simdvectorizationperformance
🎮 Playground
Benchmarking with Criterion
intermediate
Proper performance measurement
Performance Optimization
benchmarkcriterionperformance
🎮 Playground