anagram pattern is normalized

This commit is contained in:
boyska 2020-05-19 00:08:51 +02:00
parent 86b9a60648
commit 3184fc4ccf

View file

@ -64,8 +64,6 @@ fn matches_regexp(regexp: &str) -> (impl std::ops::FnMut(&&String) -> bool) {
move |w| re.is_match(w.as_str())
}
fn sort_word(word: &str) -> Result<String, impl std::error::Error> {
// funzione ausiliaria, utile per la is_anagram e cose simili
// ritorna una COPIA
@ -77,7 +75,7 @@ fn sort_word(word: &str) -> Result<String, impl std::error::Error> {
fn is_anagram(word: &str) -> (impl std::ops::FnMut(&&String) -> bool) {
// filtro
let sorted_word = sort_word(word).unwrap();
let sorted_word = sort_word(line_to_word(word.to_string()).as_str()).unwrap();
move |w| {
sorted_word == sort_word(w.as_str()).unwrap()
}