jweinst1
5/10/2019 - 7:25 AM

hash map usage in rust

hash map usage in rust


use std::collections::HashMap;
// Rust hash maps example

fn main() {
   let mut vars:HashMap<String, u32> = HashMap::new();
   vars.insert("foo".to_string(), 40);
   vars.insert("doo".to_string(), 40);
   match vars.get("soo") {
       Some(val) => println!("the value in dict is {}", val),
       None => panic!("Value not found!")
   }
}