I found this solution for choosing the anagram for a specific word :
pub fn anagrams_for<'a>(word: &str, possible_anagrams: &[&'a str]) -> HashSet<&'a str> {
let mut result = HashSet::new();
let len = word.len();
let lower = word.to_lowercase();
let mut chars: Vec<char> = lower.to_lowercase().chars().collect();
chars.sort();
for e in possible_anagrams {
if len != e.len() || lower == e.to_lowercase() {
continue;
}
let mut test: Vec<char> = e.to_lowercase().chars().collect();
test.sort();
if test == chars {
result.insert(*e);
}
}
result
}
I am confused about the type of possible_anagrams: &[&'a str]
We are borrowing a string already borrowed ?
What does ' stand for before the a ?
Thanks