Hello
I try to solve the anagram problem of exercism where I have to find anagrams of a word where the word itself is not a anagram.
So far I have this :
use std::collections::HashSet;
pub fn anagrams_for<'a>(word: &str, possible_anagrams: &[&str]) -> HashSet<&'a str> {
possible_anagrams.retain { |&word_to_check| isAnagram word &word_to_check}
}
pub fn isAnagram(word: &str, word_to_check: &str) -> bool {
if word == word_to_check {
return false
}
if word.sort() == word_to_check.sort {
return true ;
}
else {
return false;
}
}
but I see 3 compile errors where I have no idea how to solve them :
Compiling anagram v0.0.0 (C:\Users\rwobb\Exercism\rust\anagram)
error: expected one of `(`, `.`, `::`, `;`, `?`, `}`, or an operator, found `{`
--> src\lib.rs:4:30
|
4 | possible_anagrams.retain { |&word_to_check| isAnagram word &word_to_check}
| ^ expected one of 7 possible tokens
error: expected one of `(`, `.`, `::`, `;`, `?`, `}`, or an operator, found `{`
--> src\lib.rs:4:30
|
4 | possible_anagrams.retain { |&word_to_check| isAnagram word &word_to_check}
| ^ expected one of 7 possible tokens
error[E0599]: no method named `sort` found for reference `&str` in the current scope
--> src\lib.rs:13:13
|
13 | if word.sort() == word_to_check.sort {
| ^^^^ method not found in `&str`
error[E0609]: no field `sort` on type `&str`
--> src\lib.rs:13:37
|
13 | if word.sort() == word_to_check.sort {
| ^^^^
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0599, E0609.
For more information about an error, try `rustc --explain E0599`.
error: could not compile `anagram`.
warning: build failed, waiting for other jobs to finish...
error[E0599]: no method named `sort` found for reference `&str` in the current scope
--> src\lib.rs:13:13
|
13 | if word.sort() == word_to_check.sort {
| ^^^^ method not found in `&str`
error[E0609]: no field `sort` on type `&str`
--> src\lib.rs:13:37
|
13 | if word.sort() == word_to_check.sort {
| ^^^^
error: aborting due to 3 previous errors
someone wo can teach me how I can solve them ?