Convert a Vec of tuples to a HashMap using into_iter() and collect().
Use the into_iter() method on the vector and the collect() adapter to transform it into a HashMap.
use std::collections::HashMap;
let pairs = vec![("a", 1), ("b", 2)];
let map: HashMap<String, i32> = pairs.into_iter().collect();
This requires your vector to contain tuples where the first element is the key and the second is the value.
Converting a Vec to HashMap turns a simple list of paired items into a dictionary where you can look up values by their keys. Think of it like organizing a messy pile of index cards into a neat filing cabinet where each card has a specific label. You use this when you need fast lookups instead of scanning through a list.