The function signature for Anagrams in Rust is missing a lifetime

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>

(cc @senekor)

That is correct, thank you for the report @cafce25

PR with the fix

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.