In the Anagram exercise the function signature is pub fn anagrams_for<'a>(word: &str, possible_anagrams: &[&str]) -> HashSet<&'a str>
when in reality the lifetime of the output string slices should be bound to the string slices of possible_anagrams
to enable returning the same references.
It should simply be changed to pub fn anagrams_for<'a>(word: &str, possible_anagrams: &[&'a str]) -> HashSet<&'a str>
That is correct, thank you for the report @cafce25
Thanks for moving / tagging @iHiD, I’m not subscribed to the bugs & feature requests topic so I didn’t get an email at first.
1 Like
For future reference, turns out this was intentional. It is supposed to be a little challenge for users to fix the lifetime. This is mentioned in the exercise instructions (append).
I reverted the change in this PR.