]> git.proxmox.com Git - rustc.git/blobdiff - src/doc/book/listings/ch08-common-collections/listing-08-21/src/main.rs
New upstream version 1.63.0+dfsg1
[rustc.git] / src / doc / book / listings / ch08-common-collections / listing-08-21 / src / main.rs
index 0ebd20d4e81cca7f5c8328b417bc99c7c72e0bb2..508e33cbbf83975d27e36c83837d18afad026bce 100644 (file)
@@ -2,10 +2,12 @@ fn main() {
     // ANCHOR: here
     use std::collections::HashMap;
 
-    let teams = vec![String::from("Blue"), String::from("Yellow")];
-    let initial_scores = vec![10, 50];
+    let mut scores = HashMap::new();
 
-    let mut scores: HashMap<_, _> =
-        teams.into_iter().zip(initial_scores.into_iter()).collect();
+    scores.insert(String::from("Blue"), 10);
+    scores.insert(String::from("Yellow"), 50);
+
+    let team_name = String::from("Blue");
+    let score = scores.get(&team_name);
     // ANCHOR_END: here
 }