trpl-zh-cn/listings/ch08-common-collections/no-listing-03-iterate-over-hashmap/src/main.rs
2022-02-06 16:43:51 +08:00

15 lines
305 B
Rust
Executable File

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
}