SHARE
TWEET

Untitled

a guest Aug 18th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top