/ Chapter8 / hashmaps / src / main.rs
main.rs
 1  fn main() {
 2      use std::collections::HashMap;
 3  
 4      let text = "hello world wonderful world";
 5  
 6      let mut map = HashMap::new();
 7  
 8      for word in text.split_whitespace() {
 9          let count = map.entry(word).or_insert(0);
10          *count += 1;
11      }
12  
13      println!("{:?}", map);
14  }