1use std::collections::HashMap;
2use std::collections::HashSet;
3
4pub fn overlap(vec: Vec<String>) -> HashSet<(String, u32)> {
18 let mut words: HashSet<(String, u32)> = HashSet::new();
19 let mut word_freq: HashMap<String, u32> = HashMap::new();
20
21 for string in vec.iter() {
23 for word in string.split_ascii_whitespace() {
25 let presumed_value: u32 = *word_freq.get(&word.to_owned()).unwrap_or(&1);
26
27 word_freq.insert(word.to_owned(), presumed_value+1);
28 }
29 }
30
31 for (k, v) in word_freq.iter() {
32 words.insert((k.clone(), *v));
33 }
34
35 println!("{:?}", words);
36
37 words
38}