Follow linting suggestions
This commit is contained in:
parent
1b96ac1177
commit
e02fb4fecd
1 changed files with 8 additions and 9 deletions
17
src/main.rs
17
src/main.rs
|
@ -34,7 +34,7 @@ impl Dictionary {
|
|||
}
|
||||
}
|
||||
|
||||
impl Iterator for Dictionary{
|
||||
impl Iterator for Dictionary {
|
||||
type Item = String;
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
if self.words.len() >= self.iter_position {
|
||||
|
@ -58,27 +58,26 @@ fn line_to_word(l: String) -> String {
|
|||
|
||||
// i filtri dovrebbero essere creati da una struct Config{} creata parsando gli argomenti
|
||||
|
||||
fn matches_regexp(regexp: &str) -> (impl std::ops::FnMut(&&String) -> bool) {
|
||||
#[allow(dead_code)]
|
||||
fn matches_regexp(regexp: &str) -> impl std::ops::FnMut(&&String) -> bool {
|
||||
// filtro
|
||||
let re = Regex::new(regexp).unwrap();
|
||||
move |w| re.is_match(w.as_str())
|
||||
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
|
||||
// esempio: house -> ehosu
|
||||
let mut w_bytes = word.to_string().clone().into_bytes();
|
||||
let mut w_bytes = word.to_string().into_bytes();
|
||||
w_bytes.sort();
|
||||
String::from_utf8(w_bytes)
|
||||
}
|
||||
|
||||
fn is_anagram(word: &str) -> (impl std::ops::FnMut(&&String) -> bool) {
|
||||
fn is_anagram(word: &str) -> impl std::ops::FnMut(&&String) -> bool {
|
||||
// filtro
|
||||
let sorted_word = sort_word(line_to_word(word.to_string()).as_str()).unwrap();
|
||||
move |w| {
|
||||
sorted_word == sort_word(w.as_str()).unwrap()
|
||||
}
|
||||
let sorted_word = sort_word(line_to_word(word).as_str()).unwrap();
|
||||
move |w| sorted_word == sort_word(w.as_str()).unwrap()
|
||||
}
|
||||
|
||||
// filtri }}}
|
||||
|
|
Reference in a new issue