Learning Paths
Curated sequences from functional foundations to advanced systems FP — select a path to focus.
List Operations & Basic Algorithms
Core list operations, basic algorithms, and foundational data structures: last element, reverse, slice, duplicates, basic math sequences.
134 examples
001 — Last Element of a List
Last Two Elements
K-th Element
List Length
005 — Reverse a List
Eliminate Consecutive Duplicates
018 — Extract a Slice from a List
025 — Leap Year
Pascal's Triangle — Row Generation
417: Vec-like Collection Macros
744-unit-test-patterns — Unit Test Patterns
745-integration-test-setup — Integration Test Setup
746-doc-test-patterns — Doc Test Patterns
747-test-fixtures — Test Fixtures
748-property-based-testing — Property-Based Testing
749-fuzzing-concepts — Fuzzing Concepts
750-snapshot-testing — Snapshot Testing
752-test-doubles-taxonomy — Test Doubles Taxonomy
756-tempfile-testing — Tempfile Testing
757-golden-file-tests — Golden File Tests
758-test-isolation-patterns — Test Isolation Patterns
775-const-array-size — Const Array Size
928-reverse-list — Reverse List
942 Matrix Operations
950 Sum Of Multiples
960 Key Value Store
964 Union Find
975 Sparse Matrix
976 Matrix Multiply
978 Count Min Sketch
1003 — Leap Year
1004 — Leap Year
1122-leap-year — Leap Year
002 — List Operations
List Map From Scratch
List Filter From Scratch
Flatten Nested List
Pack Consecutive Duplicates
014 — Duplicate Elements
015 — Replicate Elements N Times
016 — Drop Every Nth Element
017 — Split a List at Position
019 — Rotate a List to the Left
020 — Remove the Kth Element
021 — Insert an Element at a Given Position
022 — Create a List Containing All Integers in a Range
023 — Extract a Given Number of Randomly Selected Elements
024 — Lotto — Draw N Different Random Numbers from the Set 1..M
List.map — Transform Every Element
025 — Generate a Random Permutation of the Elements of a List
026 — Generate the Combinations of K Distinct Objects Chosen from N Elements
027 — Group the Elements of a Set into Disjoint Subsets
063 — Stack Module
065 — Association List
077 — Matrix Operations
085 — Accumulate (Custom Map)
093 — Windows and Chunks
115-vec-patterns — Vec Iterator Patterns
Sublist Classification
Yacht Dice Scoring
Circular Buffer — Functional Queue
Sierpinski Triangle — Recursive ASCII Art
351: BTreeMap Ordered
352: BTreeSet Sorted
353: VecDeque Double-Ended Queue
355: LinkedList in Rust
356: HashMap Patterns
357: Entry API
358: IndexMap Ordered (Insertion-Order Map)
359: Multimap Pattern
365: Disjoint Set (Union-Find)
370: SmallVec Pattern
371: Circular Buffer (Ring Buffer)
379: Directed Acyclic Graph (DAG) and Topological Sort
380: Weighted Graph and Dijkstra's Algorithm
Arena Allocation Pattern
Stack Allocation Patterns
732-benchmarking-harness — Benchmarking Harness
753-bench-harness-pattern — Benchmark Harness Pattern
887-windows-chunks — Windows and Chunks
925-list-operations — List Operations
932-stack-module — Stack Module with Signature
953 Poker Hand Evaluator
954 Perfect Numbers
968 Deque
969 Circular Buffer
1000 — List Map
1001 — List Filter
Stack Module with Signature
1027-btreemap-sorted — BTreeMap: Sorted Key Iteration
1028-btreeset-ops — BTreeSet Operations
1029-hashmap-entry — HashMap Entry API
1030-hashmap-groupby — Group By with HashMap
1031-hashmap-counting — Frequency Counting with HashMap
1032-vec-deque-rotation — VecDeque Rotation
1034-linked-list-safe — Safe Linked List
1039-stack-via-vec — Stack Using Vec
1040-queue-via-deque — Queue Using VecDeque
1041-multimap — Multimap
1043-interval-map — Interval Map
1044-sorted-vec — Sorted Vec with Binary Search
1045-small-vec — Small Vector Optimization
1050-interning — String Interning
1065-combinations-sum — Combination Sum
1067-letter-combinations — Phone Keypad Letter Combinations
1121-listmap-transform-every-element — List.map: Transform Every Element
List.sort — Sort with Custom Comparator
List.partition — Split by Predicate
Generating All Subsets of a List Recursively
075 — Difference List
081 — Difference List
360: BitSet Pattern
361: Rope Data Structure
363: Arena Allocation
364: Slab Allocator
368: Persistent Data Structures
372: Skip List Pattern
375: LRU Cache
376: Bloom Filter
790-matrix-chain-multiplication — Matrix Chain Multiplication
961 Lru Cache
963 Bloom Filter
967 Priority Queue
971 Persistent List
974 Skip List
977 Bitset
1035-doubly-linked — Doubly-Linked List
1036-arena-graph — Graph with Arena Allocation
1042-bimap — Bidirectional Map
1049-persistent-map — Persistent HashMap
1057-matrix-chain — Matrix Chain Multiplication
Persistent Vector (Functional Array)
HList — Heterogeneous List
Heterogeneous Vector with Safe Downcast
Higher-Order Functions & Closures
Map, filter, fold, currying, partial application, function composition, closures, and pipeline patterns.
201 examples
Pipeline Operator
411: `macro_rules!` Basics
412: Macro Repetition Patterns
413: Macro Fragment Types (Designators)
414: Recursive Macro Patterns
415: Token Tree Munching
419: `cfg!` and Conditional Compilation
420: `env!` and `option_env!` — Compile-time Environment Variables
421: `include!`, `include_str!`, `include_bytes!`
422: Derive Macro Concepts
427: `syn` and `quote!` Basics
428: Macro Hygiene
429: Macro Scoping and Visibility
430: Macro Debugging Techniques
431: Counting Patterns in Macros
432: Macro Enum Dispatch
434: Domain-Specific Languages with Macros
435: Lazy Static Pattern
437: Test Helper Macros
438: `format_args!` and Efficient Formatting
439: Assert Variant Macros
440: Log Pattern Macros
Fn, FnMut, FnOnce
Interpreter Pattern
Finally tagless
Functor Laws
Fixed-Point Types
Futumorphism
Optics: lens pattern
Optics: iso pattern
Optics: functional rust grand tour
760-serde-derive-concept — Serde Derive Concept
761-custom-serialize-logic — Custom Serialize Logic
762-custom-deserialize-logic — Custom Deserialize Logic
766-config-file-parsing — Config File Parsing
767-versioned-data-format — Versioned Data Format
773-serde-attributes-concept — Serde Attributes Concept
776-const-fn-basics — Const Fn Basics
777-const-assert-patterns — Const Assert Patterns
779-const-lookup-table — Const Lookup Table
781-const-where-bounds — Const Where Bounds
782-const-eval-patterns — Const Eval Patterns
783-const-type-arithmetic — Const Type Arithmetic
Functors Introduction
Kleisli Composition
Traverse with Option
933-map-functor — Map / Functor
Currying and Partial Application
Hello World — Functions and Greetings
Applying a Function Twice
001 — Higher-Order Functions
Function Composition
005 — Currying and Partial Application
006 — Function Composition
051 — Applying a Function Twice
054 — Applicative Validation
074 — Currying and Partial Application (Applied)
077 — Generic Bounds
Closure Types: Fn, FnMut, FnOnce
Closure Capture Modes
Higher-Order Functions with Lifetime Constraints
Const Functions — Compile-Time Computation
Practical Lens — Deeply Nested Config Update
Semigroup
Closure Capture Rules
Closure as Argument
Closure as Return
Boxing Closures
Closure Move Semantics
Closure Partial Application
Closure Composition
Closure Currying
Recursive Closures and Y Combinator
Closure State Machine
Closure Strategy Pattern
Closure Observer Pattern
Lazy Evaluation with OnceLock
Complex Closure Environments
Closure-to-Function-Pointer Coercion
Function Pointers vs Closures
Closure Type Inference
Higher-Order Functions
Map-Reduce with Closures
Predicate Functions Pattern
Event Handler Pattern
Builder Pattern with Closures
Tap Pattern for Side Effects
Pipe Operator Simulation
FnOnce for Consuming Closures
Closures Capturing References
Async Closures
Closures in Benchmarking
Applicative Laws
778-const-fibonacci — Const Fibonacci
Applicative Functor Basics
Applicative Validation
871-generic-bounds — Generic Bounds
947 Currying Partial
Monoid Pattern
Currying, Partial Application, and Sections
Monoid — Fold with Closures and Traits
Currying, Partial Application, and Operator Sections
074 — Bifunctor
099 — Continuation-Passing Style (CPS)
Const Generics
Higher-Kinded Types Simulation
Coroutines and Generators
Continuation-Passing Style
Tagless Final
Introduction to Lenses — The Nested Update Problem
Lens Basics — Get and Set
Lens Laws
Lens Composition — Zoom Into Nested Structs
Lens Modify
Prism Basics — Optics for Enum Variants
Prism Laws
Traversal — Focus on Zero or More Targets
Affine Traversal — At Most One Focus
Iso Basics — Isomorphisms
Optics Hierarchy
Functor Category — Functors as Objects, Natural Transformations as Morphisms
Natural Transformations
Monoid as a Category
Functor Comparable Set
383: Simulating Higher-Kinded Types with GATs
423: Procedural Macro Introduction
424: Proc Macro Derive
425: Proc Macro Attribute
426: Function-like Proc Macros
Closure Memoization
Continuation-Passing Style (CPS)
Optics: optics intro
Optics: prism pattern
Optics: affine traversal
Optics: classy optics
774-const-generics-basics — Const Generics Basics
780-const-generic-struct — Const Generic Struct
Lenses
Tail-Recursive Map with CPS
Lenses — Functional Getters and Setters
Introduction to Free Monads
Console DSL with Free Monad
Free Monad Interpreters
Free Monad with State
Operational Monad
Introduction to Algebraic Effects
Effect Handlers
Effects as Exceptions
Effects as State
Effects as Async
Delimited Continuations
Scott Encoding
Van Laarhoven Lenses
Anamorphism — Unfold to Build Recursive Structures
Hylomorphism — Ana then Cata, Fused
Paramorphism — Cata with Access to Original Subtree
Apomorphism — Ana that Can Short-Circuit
Histomorphism — Cata with Full History
Zygomorphism — Two Mutually Dependent Folds
Mutumorphism — Genuinely Mutual Recursion
Prepromorphism — Apply Natural Transformation at Each Step
Category Basics
Curry-Howard Correspondence
Propositions as Types
Yoneda Lemma
Coyoneda
Day Convolution
Profunctor Basics
Strong Profunctor
Choice Profunctor
Comonad Basics
Store Comonad
Environment Comonad
Comonad Laws
Cofree Comonad
Adjunctions
Limits and Colimits
Kan Extensions
Monad from Adjunction
Grand Synthesis
Scott encoding rust
Free monad rust
Effect system sim
Monad Laws
Anamorphism
Hylomorphism
Paramorphism
Zygomorphism
Histomorphism
Optics: traversal optics
Optics: profunctor optics
Option Monad
State Monad
Reader Monad
Writer Monad
Monad Transformers
Sequence Monadic
869-continuation-monad — Continuation Monad
941 Identity Monad
949 Profunctor Intro
Writer Monad — Logging Computation
Error Handling FP Style
Result, Option, monadic error composition, async patterns, and concurrency.
156 examples
Option Type — Safe List Maximum
441: Thread Basics — Spawn and Join
442: Scoped Threads — Borrowing Across Threads
446: Thread Pool Pattern
448: Rayon Parallel Iterators — Data Parallelism
449: Rayon Join — Fork-Join Parallelism
450: Crossbeam Channels — Advanced Channel Patterns
451: Crossbeam Select — Multiplexing Channels
459: Thread-Local Storage
462: Pipeline Concurrency
463: Fan-Out / Fan-In Pattern
465: Message Passing vs. Shared Memory
Concurrent HashMap
Parallel Reduce
Concurrent BTree
ffi error codes
741-parse-dont-validate — Parse Don't Validate
754-testing-async-code — Testing Async Code
755-testing-error-paths — Testing Error Paths
Traverse with Result
923-thread-pool — Thread Pool
979 Future Basics
983 Channel Basics
984 Channel Pipeline
985 Select Pattern
988 Thread Local
989 Once Init
990 Semaphore
994 Map Reduce
995 Pipeline Stages
List Filter — Select Elements by Predicate
004 — Option and Result
041 — Option Basics
042 — Option Map
043 — Option Bind (and_then)
044 — Option Filter
045 — Result Basics
046 — Result Map
047 — Result Bind (and_then)
048 — Error Propagation with the ? Operator
049 — Error Conversion
050 — Custom Error Types
072 — Error Accumulation (Validation Type)
072 — Railway-Oriented Programming
073 — Validated Types (Parse, Don't Validate)
Monadic Option Chaining
Result Monad — Error Chaining
Parallel Letter Frequency
291: Result Combinators
292: Option Combinators
293: The ? Operator
294: Custom Error Types
295: Implementing std::error::Error
296: From Trait for Error Conversion
297: The thiserror Pattern
298: The anyhow Pattern — Boxed Errors
299: Adding Context to Errors
300: Chaining Errors with source()
301: Result::transpose() — Flipping Nested Types
302: Option::transpose() — Collecting Optional Results
304: Splitting Ok/Err with partition()
305: unwrap_or, unwrap_or_else, unwrap_or_default
306: ok_or and ok_or_else
307: Error Propagation in Closures
308: When to Panic vs Return Result
310: Infallible Conversions
311: Handling Multiple Error Types
312: Error Downcasting
313: The Try Trait — What ? Actually Does
315: Result ok() and err() Methods
316: std::io::Error Patterns
317: Parse Error Handling
318: Display vs Debug for Errors
319: Error Handling in Tests
321: async fn and .await Fundamentals
323: async blocks and Lazy Evaluation
328: Async Channels (mpsc)
341: Buffered Stream — BufReader and BufWriter
341: MPSC Channel
343: Producer-Consumer Pattern
350: Oneshot Channel
445: MPSC Channels — Message Passing Between Threads
461: Producer-Consumer Pattern
920-buffered-stream — Buffered Stream
927-option-result — Option and Result
943 Result Railway
944 Validated Type
980 Async Map
981 Async Sequence
993 Work Queue
1001 — Event Loop
1003 — Custom Error Types
1004 — Error Conversion
1005 — Error Chaining
1006 — Multiple Error Types
1007-result-combinators — Result Combinators
1008-option-to-result — Option to Result
1009-collecting-results — Collecting Results
1010-partition-results — Partition Results
1011-try-operator — The ? (Try) Operator
1013-panic-vs-result — Panic vs Result
1014-recover-from-panic — Recover from Panic
1015-validation-error — Validation Errors
1016-error-context — Error Context
1017-typed-errors — Typed Error Hierarchies
1018-error-downcast — Error Downcast
1021-error-propagation-depth — Error Propagation Depth
1022-sentinel-vs-result — Sentinel Values vs Result
1023-parse-int-safe — Safe Integer Parsing
1024-file-errors — File Operation Errors
1025-network-errors — Network Error Classification
1026-error-display — Custom Error Display and Source Chain
List.fold_left — Accumulate a Result
1124-listfilter-select-elements-by-predicate — List.filter: Select Elements by Predicate
Error Recovery
309: The Never Type (!) in Error Handling
314: Validated — Accumulating All Errors
324: Running Futures Concurrently with join!
325: Racing Futures with select!
327: Spawning Concurrent Tasks
329: Async Streams
330: Async Sink — Buffered Writing
331: Timeouts with time::timeout
332: Retry Async with Exponential Backoff
333: Async Recursion
334: Pin and Unpin
336: Executor Basics
337: Async Mutex
338: Async RwLock — Multiple Readers, One Writer
339: Semaphore — Controlling Concurrency
342: Async I/O Concepts
343: Cancellation Token
344: Structured Concurrency
345: Async Drop
346: Runtime Context
347: Blocking in Async
348: Async Generator Pattern
349: Broadcast Channel
447: Work Stealing — Load Balancing Across Threads
458: Barrier Synchronization
464: Actor Pattern
921-async-io — Async I/O
922-cancellation-token — Cancellation Token
924-work-stealing — Work Stealing
982 Async Join
991 Barrier Sync
992 Actor Pattern
996 Timeout Pattern
997 Retry Backoff
998 Circuit Breaker
999 Rate Limiter
1000 — Reactive Stream
1002 — Backpressure
056 — Result as a Monad
335: Waker and Context
Result Monad
Strings, Vectors & Data Types
String operations, vector manipulation, basic structs, records, and pattern matching.
114 examples
006 — Palindrome Check
062 — Isogram Check
068 — Frequency Counter (Map Module)
070 — Hamming Distance
082 — Nucleotide Count
084 — Phone Number Validation
086 — Space Age
091 — Caesar Cipher
092 — Pangram Check
093 — Isogram Check
102-frequency-counter — Frequency Counter
String Anagram Check
Caesar Cipher — Functional Encryption
Hamming Distance — Generic Zip
418: `stringify!` and `concat!` Macros
String vs &str
String Slices
String Parsing with FromStr
String Formatting
String Building
String Splitting
String Trimming
String Searching
String Replacing
String Chars
String Bytes
String Unicode
String Encoding
Cow<str> Usage
String Concatenation
String Regex Pattern
String Owning References
Arc<str> for Shared Strings
String Fixed Array
Path and PathBuf
OsStr Handling
CString and CStr for FFI
String-Number Conversion
String Template Pattern
String Diff Pattern
String Case Conversion
String Truncation
String Escaping
String Compression — Run-Length Encoding
ffi string conversion
730-small-string-optimization — Small String Optimization
763-json-format-from-scratch — JSON Format From Scratch
769-streaming-parser-pattern — Streaming Parser Pattern
771-pratt-parser — Pratt Parser
Polynomial String Hashing
929-palindrome-check — Palindrome Check
930-pangram-check — Pangram Check
945 Word Count
952 Atbash Cipher
955 Json Value
956 Json Pretty Print
957 Json Query
959 Csv Writer
970 Rope String
1125-reverse-string — Reverse a String
Run-Length Encoding
011 — Modified Run-Length Encoding
012 — Decode Run-Length Encoding
013 — Direct Run-Length Encoding
036 — Represent a Binary Tree as a String
039 — Convert a Tree to a Dotstring Representation
040 — Parse a Dotstring Back to a Binary Tree
063 — Run-Length Encoding
064 — Balanced Parentheses
083 — Robot Simulator
088 — Allergies
089 — Bob
Frequency Analysis — Letter Distribution
094 — Run-Length Encoding
095 — Balanced Parentheses
113-string-str — String vs &str
CSV Parser
Binary ↔ Decimal Fold
String Interning
765-csv-parsing-pattern — CSV Parsing Pattern
787-edit-distance-levenshtein — Edit Distance (Levenshtein)
794-word-break-dp — Word Break
958 Csv Parser
1056-edit-distance — Edit Distance (Levenshtein)
1061-word-break — Word Break
096 — Recursive Descent Parser
Introduction to Parser Combinators
Character Parsers
Satisfy Parser
String Parser
Many Parser
Optional Parser
Choice Parser
Sequence Parser
Map Parser
FlatMap Parser
Digit Parser
Identifier Parser
Whitespace Parser
Number Parser
Keyword Parser
Separated List
Recursive Parser
Expression Parser
Operator Precedence
INI File Parser
Lisp / S-expression Parser
Arithmetic Expression Evaluator
Complete JSON Parser
764-binary-format-encoding — Binary Format Encoding
770-recursive-descent-parser — Recursive Descent Parser
772-parser-combinator-pattern — Parser Combinator Pattern
791-palindrome-partitioning — Palindrome Partitioning
Manacher's Algorithm — Longest Palindromic Substring
Pattern Matching & Types
Algebraic data types, sum types, traits, type system, and pattern-based destructuring in Rust.
151 examples
Variants — Days of the Week
407: The Default Trait
409: Drop Trait and RAII
410: Arithmetic Operator Overloading
433: Macro-Defined State Machines
Or Patterns
Pattern Guards
Struct Destructuring
Enum Variant Patterns
Tuple Struct Patterns
Nested Patterns
Pattern Binding Modes
@ Bindings
Slice Patterns
.. and _ Wildcards
Ref Patterns
let-else Pattern
if-let and while-let
Let Chains (&&)
matches! Macro
Irrefutable vs Refutable Patterns
Pattern Exhaustiveness
String Pattern Matching
Option Pattern Matching
Tuple Pattern Matching
Pattern Const Patterns
Pattern Type Ascription
Pattern Box Deref
Pattern Multiple Arms
Pattern Visitor Match
Pattern State Automata
Pattern Command Dispatch
Pattern Advanced Enums
Command Pattern (Functional Style)
Coproduct Types (Sum Types)
Advanced Product Types
743-session-types — Session Types
751-mock-trait-pattern — Mock Trait Pattern
759-manual-serialize-trait — Manual Serialize Trait
Foldable Trait
003 — Pattern Matching
062 — Records (Structs)
076 — Trait Objects (Dynamic Dispatch)
078 — Where Clauses
079 — Associated Types
081 — Newtype Pattern
082 — Type Aliases
083 — Display Trait
084 — From and Into Traits
102-clone-copy — Clone vs Copy
114-slice-patterns — Slice Patterns
Deref Coercions
impl Trait in Function Signatures
dyn Trait — Dynamic Dispatch
Generic Newtype Patterns
Sealed Traits
Extension Traits
Product Types
Sum Types
State Machine — Turnstile
384: Trait Objects and `dyn Trait`
385: Trait Objects and `Any` (Runtime Type Information)
386: Object-Safe Traits
387: Sealed Trait Pattern
388: Extension Trait Pattern
389: Newtype Pattern
390: Type Alias and `impl Trait`
391: `impl Trait` in Return Position
392: `impl Trait` in Argument Position
393: Trait Bounds and Where Clauses
394: Supertrait Pattern
395: Default Methods in Traits
396: Simulating Trait Specialization
397: Marker Traits
400: Static vs. Dynamic Trait Dispatch
401: Deref and Deref Coercions
402: Index and IndexMut Traits
403: Display and Debug Traits
404: From, Into, TryFrom, TryInto
406: Hash, Eq, and Ord Traits
408: Clone and Copy Traits
Lifetimes in dyn Trait
Range Patterns
Result Pattern Matching
814-kmp-pattern-matching — KMP Pattern Matching
870-trait-objects — Trait Objects (Dynamic Dispatch)
872-where-clauses — Where Clauses
873-associated-types — Associated Types
875-newtype-pattern — Newtype Pattern
876-type-aliases — Type Aliases
877-display-trait — Display Trait
878-from-into-traits — From/Into Traits
896-clone-copy — Clone and Copy Traits
926-pattern-matching — Pattern Matching
931-records — Records and Functional Update
Monoid Pattern — Trait-Based Combining
066 — Phantom Types (Type-Safe Units)
100 — Phantom Types
Zero-Cost Abstractions
Send and Sync Marker Traits
Type-Level Booleans
Type-Level Natural Numbers — Peano Arithmetic
Typestate Pattern — State Machines in Types
Builder Pattern with Typestate
Phantom Units of Measure
Variance — Covariance, Contravariance, Invariance
Type Witnesses / GADT Encoding
Associated Type Bounds
Generic Associated Types (GAT) Basics
GAT Collections
Opaque Types
Type Erasure
Coherence Rules
PhantomData for API Safety
Type-Safe SQL-like Query Builder
322: The Future Trait and Poll
340: Async Trait Pattern
381: Blanket Implementations
382: Associated Types (Advanced)
398: Auto Traits (`Send`, `Sync`, `Unpin`)
399: Coherence and Orphan Rules
416: Macro-Generated Builder Pattern
436: Newtype Derive Patterns
460: `Send` and `Sync` Bounds
Variance: Covariant, Contravariant, Invariant
Functional Builder Pattern
unsafe trait
734-typestate-basics — Typestate Basics
735-typestate-builder — Typestate Builder
736-typestate-connection — Typestate Connection
737-typestate-file-handle — Typestate File Handle
738-phantom-type-basics — Phantom Type Basics
739-phantom-units-of-measure — Phantom Units of Measure
740-phantom-variance-control — Phantom Variance Control
742-type-witnesses — Type Witnesses
874-phantom-types — Phantom Types
1012-never-type — The Never Type (!)
Visitor Pattern via Fold — Expression Evaluator
Monoid Pattern — Generic Combining
079 — Lambda Calculus Interpreter
Existential Types
Rank-2 Types Simulation
Type-Safe Printf
Singleton Types
Type Equality
Introduction to GADTs
GADT Typed Expression Evaluator
Length-Indexed Lists
GADT Preventing Runtime Errors — Safe Head
Existential Types via Box<dyn Trait>
Phantom Type State Machine — File Handle
Data Structures & Collections
Trees, maps, graphs, advanced data structures, lifetimes, and memory safety.
135 examples
453: Memory Ordering
454: Compare-and-Exchange (CAS)
456: `OnceLock` and `OnceCell` — Once-Initialized Values
457: Condition Variable Pattern
Epoch-Based Garbage Collection
Raw Pointer Basics
raw pointer arithmetic
dereferencing raw ptr
null pointer check
transmute basics
transmute safe patterns
unions in rust
extern c functions
no mangle export
ffi repr c structs
ffi callbacks
volatile memory
soundness principles
Struct of Arrays (SoA) Pattern
Cache-Friendly Iteration
MaybeUninit — Safe Uninitialized Memory
Memory Layout and `repr` Attributes
Zero-Copy Parsing
Memory Pool Pattern
Portable SIMD Concepts
728-inline-hints — Inline Hints
731-tiered-memory-strategy — Tiered Memory Strategy
733-profile-guided-patterns — Profile-Guided Patterns
768-zero-copy-deserialize — Zero-Copy Deserialize
Interval Tree — Stabbing Queries
867-foldable-tree — Foldable Tree
868-traversable-tree — Traversable Tree
935-tree-map-fold — Tree Map and Fold
986 Mutex Basics
987 Rwlock Pattern
029 — Binary Tree (Algebraic Data Type)
030 — Count the Leaves of a Binary Tree
032 — Collect the Internal Nodes of a Binary Tree
033 — Collect the Nodes at a Given Level
034 — Construct a Complete Binary Tree
035 — Layout a Binary Tree
037 — Preorder Traversal Sequence
038 — Inorder Traversal Sequence
Recursive Variant — Expression Tree
061 — Binary Tree (Size, Membership, Traversal)
101-move-semantics — Move Semantics
103-borrowing-shared — Shared Borrowing
104-borrowing-mutable — Mutable Borrowing
105-lifetime-basics — Lifetime Basics
105-trie — Trie (Prefix Tree)
106-lifetime-elision — Lifetime Elision Rules
107-lifetime-structs — Lifetimes in Structs
Rc\<T\> — Shared Ownership
110-cell-interior — Cell<T>: Interior Mutability for Copy Types
116-box-heap — Box<T>: Heap Allocation
Binary Search Tree — Insert and Search
Rose Tree — Multi-Way Tree with Fold
362: Trie Structure
Lifetime Annotations: 'a Basics
Multiple Lifetime Parameters
Lifetimes in Structs
Lifetimes in impl Blocks
Lifetimes in Enums
'static Lifetime
Lifetime Coercion and Subtyping
Non-Lexical Lifetimes (NLL)
Borrow Checker Internals
Lifetime Elision Rules
Higher-Ranked Trait Bounds (for<'a>)
Lifetimes in Closures
Split Borrows from Structs
Reborrowing Patterns
Polonius Borrow Checker Concepts
Named Return Lifetimes
PhantomData for Lifetime Markers
Rc and Weak for Shared Ownership
Safe Transmute Patterns
Owning References Pattern
Rental Pattern
Output Lifetime Patterns
Input Lifetime Patterns
Region Inference
Lifetime Cheatsheet
Trie Autocomplete
895-move-semantics — Move Semantics
897-borrowing-shared — Shared Borrowing (&T)
898-borrowing-mutable — Mutable Borrowing (&mut T)
899-lifetime-basics — Lifetime Basics
962 Trie Map
Map and Fold on Trees
1047-flat-tree — Flat Binary Tree in Vec
Huffman Encoding — Greedy Tree Building
097 — Zipper
109-arc-threads — Arc<T>: Thread-Safe Shared Ownership
RefCell<T> — Runtime Borrow Checking
112-cow-clone-on-write — Cow<T>: Clone on Write
AVL Tree — Self-Balancing BST
Tree Zipper
326: Capturing with async move
342: Arc<Mutex<T>> Pattern
354: BinaryHeap Priority Queue
366: Segment Tree
367: Fenwick Tree (Binary Indexed Tree)
369: Clone-on-Write (Cow)
373: Custom B-Tree Implementation
374: Radix Tree (Compressed Trie)
443: `Arc<Mutex<T>>` — Shared Mutable State
444: `Arc<RwLock<T>>` — Multiple Readers, One Writer
452: Atomic Types — Lock-Free Concurrent Primitives
Cell and RefCell for Interior Mutability
Self-Referential Structs
Unsafe Blocks
Unsafe Functions
unsafe cell
global allocator
Branchless Programming
729-avoid-allocations — Avoid Allocations
965 Segment Tree
966 Fenwick Tree
972 Persistent Tree
973 Finger Tree
Binary Tree — Size, Membership, Traversal
1033-binary-heap-topk — Top-K with BinaryHeap
1046-cow-collections — Clone-on-Write Collections
1048-zipper-vec — Vec Zipper
Red-Black Tree
Red-Black Tree — Balanced Insert
Red-Black Tree — Balanced Insert (Iterator + Free Functions)
Red-Black Tree — Okasaki's Functional Balanced Insert
Red-Black Tree with Balanced Insert
Red-Black Tree with Okasaki's Functional Balancing
1165-building-a-huffman-tree-from-character-frequencies — Huffman Encoding: Greedy Tree Building
Trie-based Persistent Vector for O(log n) Random Access
455: Lock-Free Stack
Lock-Free Queue
Iterators & Transformation
Map, filter, fold, and lazy iteration patterns from OCaml to Rust.
106 examples
FlatMap / Bind Chains
031 — Collect the Leaves of a Binary Tree in a List
fold_right — Structural Recursion
fold_left — Tail-Recursive Accumulator
067 — Lazy Sequences (Seq Module)
070 — Scan Left (Running Accumulation)
085 — Iterator Trait
086 — Custom Iterator with State
087 — Iterator Adapters
088 — Iterator Consumers
089 — Lazy Sequences
090 — Infinite Iterators
091 — Zip and Unzip
092 — Scan Accumulate
094 — Peekable Iterator
095 — Double-Ended Iterator
096 — Exact Size Iterator
097 — Flatten and Flat Map
098 — Partition Iterator
099 — Group Consecutive Equal Elements
100 — Step By
Lazy Sequences
104-scan-left — Scan Left (Running Accumulation)
Lazy Fibonacci
256: Chaining Iterators with chain()
257: Pairing Elements with zip()
258: Index-Value Pairs with enumerate()
259: Flattening with flat_map()
260: Stateful Accumulation with scan()
261: Lookahead with Peekable
262: Sliding Windows over Slices
263: Fixed-Size Chunks Iteration
264: Conditional Stopping with take_while()
265: Conditional Skipping with skip_while()
266: Striding with step_by()
267: Infinite Cycling with cycle()
268: Splitting Pairs with unzip()
269: Splitting by Predicate with partition()
270: Finding Index with position()
271: Transform-and-Find with find_map()
272: One-Level Flattening with flatten()
273: Debugging Iterators with inspect()
274: Numeric Reductions: sum() and product()
275: Finding Extremes with min() and max()
276: Custom Comparison with min_by() and max_by()
277: Counting Elements with count()
278: Getting the Last Element with last()
279: Random Access with nth()
280: Existential Checks with any() and all()
281: Implementing the Iterator Trait from Scratch
282: DoubleEndedIterator and rev()
283: ExactSizeIterator for Known-Length Iterators
284: FusedIterator for Stable Termination
285: Building Custom Iterator Adapters
286: Creating Iterators with from_fn()
287: Recursive Sequences with successors()
288: Materializing Iterators with collect()
289: Extending Collections with extend()
290: Advanced Splitting Patterns
303: Collecting Iterator<Result<T>> into Result<Vec<T>>
320: Fallible Iterators
405: Iterator Trait Deep Dive
879-iterator-trait — Iterator Trait
880-custom-iterator — Custom Iterator
881-iterator-adapters — Iterator Adapters
882-iterator-consumers — Iterator Consumers
883-lazy-sequences — Lazy Sequences
884-infinite-iterators — Infinite Iterators
885-zip-unzip — Zip and Unzip
886-scan-accumulate — Scan / Accumulate
888-peekable-iterator — Peekable Iterator
889-double-ended — DoubleEndedIterator
890-exact-size — ExactSizeIterator
891-flatten-iterator — Flatten Iterator
892-partition-iterator — Partition Iterator
893-group-by-iter — Group By Iterator
894-step-by — Step By, Enumerate, Rev
900-iterator-chain — Iterator Chain
901-iterator-zip — Iterator Zip
902-iterator-enumerate — Iterator Enumerate
903-iterator-flat-map — Iterator flat_map
904-iterator-scan — Iterator Scan
905-iterator-peekable — Iterator Peekable
906-iterator-windows — Iterator Windows
907-iterator-chunks — Iterator Chunks
908-iterator-take-while — Iterator take_while
909-iterator-skip-while — Iterator skip_while
910-iterator-find-map — Iterator find_map
911-iterator-flatten — Iterator Flatten
912-iterator-inspect — Iterator Inspect
913-iterator-sum-product — Iterator Sum and Product
914-iterator-min-max — Iterator min and max
915-iterator-min-by-max-by — Custom Comparison min_by / max_by
916-iterator-count — Iterator Count
917-iterator-last — Iterator Last
918-iterator-nth — Iterator nth
919-iterator-any-all — Iterator any and all
939 Scan Left
951 Series Sliding Window
1002 — List Fold Left
1019-fallible-iterator — Fallible Iterator
1020-try-fold — try_fold
069 — Unfold — Generate a Sequence from a Seed
103-unfold — Unfold: Generating Sequences from Seeds
Fold Optic — Read-Only Multi-Focus Aggregation
938-unfold — Unfold
Recursion & Induction
Recursive patterns, tail-call optimization, graphs, algorithms, and structural induction.
126 examples