count words in string
// Count words (text separated by whitespace) in a piece of text
use std::collections::HashMap;
fn word_count(text: &str) -> HashMap<&str, i32> {
let mut map = HashMap::new();
for word in text.split_whitespace() {
*map.entry(word).or_insert(0) += 1;
}
map
}
fn main() {
println!("Count of words = {:?} ",word_count("the quick brown fox jumped over the lazy dog"));
}