summaryrefslogtreecommitdiffstats
path: root/src/doc/book/listings/ch08-common-collections/no-listing-03-iterate-over-hashmap/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/doc/book/listings/ch08-common-collections/no-listing-03-iterate-over-hashmap/src/main.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/doc/book/listings/ch08-common-collections/no-listing-03-iterate-over-hashmap/src/main.rs b/src/doc/book/listings/ch08-common-collections/no-listing-03-iterate-over-hashmap/src/main.rs
new file mode 100644
index 000000000..2e7dc02e6
--- /dev/null
+++ b/src/doc/book/listings/ch08-common-collections/no-listing-03-iterate-over-hashmap/src/main.rs
@@ -0,0 +1,14 @@
+fn main() {
+ // ANCHOR: here
+ use std::collections::HashMap;
+
+ let mut scores = HashMap::new();
+
+ scores.insert(String::from("Blue"), 10);
+ scores.insert(String::from("Yellow"), 50);
+
+ for (key, value) in &scores {
+ println!("{}: {}", key, value);
+ }
+ // ANCHOR_END: here
+}