← Rust Programming learning pathRust Programming · Module 7 of 10
Collections and iterators
Use Vec, HashMap and iterator adaptors.
📖 Key ideas
- Vec<T> is a growable array: vec![1, 2, 3].
- HashMap<K, V> maps keys to values.
- Iterators: iter(), map, filter, collect.
- for item in &v borrows elements.
- Iterators are lazy and zero-cost.
💡 Real-life example: Iterator chains are assembly lines: each station transforms items as they pass through.
VecGrowable vector
HashMapKey-value map
iter()Creates an iterator
collect()Builds a collection from an iterator