A HashVec is a hash map / dictionary whose key-value pairs are stored (and can be iterated over) in a fixed order, by default the order in which they were inserted into the map. It's essentially a vector whose values can be inserted/retrieved with keys.
```rust // Create a new hashvec containing pairs of animal names and species let mut hashvec: HashVec<&'static str, &'static str> = HashVec::new();
// Insert values into the hashvec hashvec.insert("Doug", "Kobold"); hashvec.insert("Skye", "Jaguar"); hashvec.insert("Lee", "Shiba"); hashvec.insert("Sock", "Man"); hashvec.insert("Salad", "Dog"); hashvec.insert("Finn", "Human"); hashvec.insert("Jake", "Dog");
// Access a value by key match hashvec.get("Finn") { Some(value) => { assert_eq!(*value, "Human"); }, None => {} }
// Access an entry by index let leevalue = hashvec[2]; asserteq!(lee_value, ("Lee", "Shiba"));
// Get the index of a key let leeindex = hashvec.index("Lee").unwrap(); asserteq!(lee_index, 2);
// Mutate a value match hashvec.getmut("Sock") { Some(value) => { *value = "Guinea Pig"; }, None => {} } asserteq!(*hashvec.get("Sock").unwrap(), "Guinea Pig");
// Remove a value hashvec.remove("Doug"); assert_eq!(hashvec.get("Doug"), None);
// Iterate over each of the key-value pairs in the hashvec for (k, v) in hashvec.into_iter() { println!("{} is a {}!", k, v); }
// Clear the hashvec hashvec.clear(); ```