Advertisement
Guest User

Untitled

a guest
Apr 21st, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. use std::collections::HashMap;
  2.  
  3.  
  4.  
  5.  
  6.  
  7. fn basic_hash_map_ops() {
  8. let mut scores = HashMap::new();
  9. // let mut scores = HashMap<String, HashMap<U32, u32>>::new();
  10.  
  11. let mut blue :HashMap<u32, u32> = HashMap::new();
  12. let mut yellow = HashMap::new();
  13. let mut green = HashMap::new();
  14.  
  15. blue.insert(5, 45);
  16. yellow.insert(6, 54);
  17. green.insert(7, 63);
  18.  
  19. // scores.insert(String::from("Blue"), blue);
  20. scores.insert("Blue".to_string(), blue);
  21. scores.entry(String::from("Yellow")).or_insert(yellow);
  22. scores.entry(String::from("Green")).or_insert(green);
  23.  
  24. if let Some(y) = scores.get_mut("Yellow") {
  25. y.insert(8, 72);
  26. // println!("{:?}", x);
  27. }
  28.  
  29. println!("{:?}", scores);
  30. }
  31.  
  32.  
  33. fn setting_structs() {
  34. struct
  35. }
  36.  
  37. fn main() {
  38. basic_hash_map_ops();
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement