Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. use std::collections::HashMap;
  2.  
  3. fn main() {
  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.  
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement