← Rust Programming learning path
Rust Programming · Module 7 of 10

Collections and iterators

Use Vec, HashMap and iterator adaptors.

📖 Key ideas

  1. Vec<T> is a growable array: vec![1, 2, 3].
  2. HashMap<K, V> maps keys to values.
  3. Iterators: iter(), map, filter, collect.
  4. for item in &v borrows elements.
  5. 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