I have the following code:
use std::collections::HashSet;
pub fn same_word_length<'a>(words: &[&str]) -> HashSet<&'a str> {
let result: HashSet<&'a str> = HashSet::new();
for w in words {
if w.len() == 4 {
result.insert(w.clone()); <-- lifetime 'a required
}
}
result
}
I cannot change the signature of the function.
What should I do?