Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::collections::HashMap;
- fn main() {
- let text = "hello world wonderful world";
- let mut map = HashMap::new();
- for word in text.split_whitespace() {
- let count = map.entry(word).or_insert(0);
- *count += 1;
- }
- println!("{:?}", map);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement