Collections, Iterators & Closures
Picking the right container on complexity rather than habit, then expressing the transformation lazily. Includes the Fn/FnMut/FnOnce distinction that decides what a closure may capture.
// lessons
- 01
Vec, VecDeque & Growth
Choose between them on push/pop position, and stop reallocating in a hot loop.
- 02
HashMap vs BTreeMap
Pick on ordering and complexity, not on which one you typed last time.
- 03
iter, iter_mut & into_iter
Say what each one hands you, and what it does to the collection.
- 04
Adapters & Laziness
Chain map/filter/filter_map and explain why nothing ran until collect.
- 05
fold, reduce & Custom Aggregation
Replace a mutable accumulator loop with one expression.
- 06
Fn, FnMut & FnOnce
Predict which trait a closure implements from what it captures.
- 07
move Closures & Escaping Captures
Hand a closure to something that outlives its scope, correctly.
Every exercise compiles and runs in the Forge sandbox — standard library only, no external crates.
