1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

use std::collections::HashMap;

pub fn words_count() {
    let mut short_story = String::new();
    println!("please give your short story\n    ");

    std::io::stdin().read_line(&mut short_story).expect("no stroy is given");

    let mut summary = HashMap::new();

    for word in short_story.split_whitespace() {
        let count = summary.entry(word).or_insert(0);
        *count += 1; 
    }    

    println!("\n    {:#?}", summary);

    println!("\n    The total Number of different words used in story : {}",summary.len() );

}
// #[cfg(test)]
// mod tests {
//     #[test]
//     fn it_works() {
//         assert_eq!(2 + 2, 4);
//     }
// }