Clippy code cleanup

This commit is contained in:
2026-08-15 13:22:59 +03:00
parent 9917702c4c
commit e676898135
22 changed files with 290 additions and 171 deletions
+29 -30
View File
@@ -69,25 +69,25 @@ impl NavigatedPage<DictionaryMessage> for DictionaryState {
if let Back = message {
return Some(Page::PreviousPage);
}
if let Test = message {
if self.include_map.iter().any(|x| *x) {
let mut words = vec![];
let dict = &self.state.lock().unwrap().dictionary;
if let Test = message
&& self.include_map.iter().any(|x| *x)
{
let mut words = vec![];
let dict = &self.state.lock().unwrap().dictionary;
words = self
.include_map
.iter()
.zip(0..self.include_map.len())
.filter(|(flag, _)| **flag)
.map(|(_, index)| dict[index].clone())
.collect();
words = self
.include_map
.iter()
.zip(0..self.include_map.len())
.filter(|(flag, _)| **flag)
.map(|(_, index)| dict[index].clone())
.collect();
return Some(Page::DictionaryQuiz(DictionaryQuizState::new(
words,
self.reverse,
self.no_typing,
)));
}
return Some(Page::DictionaryQuiz(DictionaryQuizState::new(
words,
self.reverse,
self.no_typing,
)));
}
if let WordAction(index) = message {
let word: WordData;
@@ -119,7 +119,7 @@ impl NavigatedPage<DictionaryMessage> for DictionaryState {
NewWord => {
let mut state = self.state.lock().unwrap();
let mut word = WordData::new();
word.group_id = state.word_groups[self.selected_group_index].id.clone();
word.group_id = state.word_groups[self.selected_group_index].id;
let dict = &mut state.dictionary;
dict.push(word);
@@ -318,7 +318,7 @@ impl DictionaryState {
let connection = &state.connection;
let word = &mut state.dictionary.get(i).unwrap().clone();
update_word(word, &connection);
update_word(word, connection);
state.dictionary[i] = word.clone();
}
@@ -353,13 +353,12 @@ impl DictionaryState {
continue;
}
if !self.search.is_empty() {
if word.key.contains(&self.search) == false
&& word.value.contains(&self.search) == false
&& word.tags.contains(&self.search) == false
{
continue;
}
if !self.search.is_empty()
&& !word.key.contains(&self.search)
&& !word.value.contains(&self.search)
&& !word.tags.contains(&self.search)
{
continue;
}
let word_line_data = WordLineState {
@@ -553,7 +552,9 @@ impl DictionaryState {
.iter()
.map(|word| (split_with_coma(word.tags.as_str()), word.group_id))
.map(|(tags, word_group_id)| {
tags.iter().all(|t| include_tags.contains(t)) && tags.len() != 0 && word_group_id == group_id
!tags.is_empty()
&& tags.iter().all(|t| include_tags.contains(t))
&& word_group_id == group_id
})
.collect();
@@ -567,14 +568,12 @@ impl DictionaryState {
let state = &self.state.lock().unwrap();
let groups = &state.word_groups;
let mut index = 0;
for group in groups {
for (index, group) in groups.iter().enumerate() {
row = row.push(
button(text!("{}", group.name.clone()))
.style(text)
.on_press(SelectGroup(index)),
);
index = index + 1;
}
let group = state.word_groups[self.selected_group_index].clone();