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
+8 -20
View File
@@ -199,14 +199,6 @@ impl KanaSet {
}
}
/* pub fn next(&mut self) -> (String, String) {
let current_set = self.list();
let mut rand = rand::rng();
let index: u32 = rand.random();
current_set[index as usize % current_set.len()].clone()
}*/
pub fn list(&self) -> Vec<(String, String)> {
let mut current_set: Vec<(String, String)> = Vec::new();
@@ -286,11 +278,7 @@ impl CardStatistics {
}
}
if self.score < 1 {
self.score = 1
} else if self.score > MAX_SCORE {
self.score = MAX_SCORE
}
self.score = self.score.clamp(1, MAX_SCORE);
self.last_open = Utc::now();
}
@@ -325,7 +313,7 @@ impl CardSet {
let state_for = state.clone();
let state_locked = state.lock().unwrap();
let mut current_set = load_stats_of_set(&settings, &state_locked.connection);
let mut current_set = load_stats_of_set(settings, &state_locked.connection);
let last_list = settings.get_word_list(&state_locked);
let saved_ids = current_set.iter().map(|l| l.word_id).collect::<Vec<u32>>();
let word_ids = last_list.iter().map(|l| l.id).collect::<Vec<u32>>();
@@ -335,10 +323,10 @@ impl CardSet {
.filter(|word| !saved_ids.contains(&word.id))
.map(|word| CardStatistics {
id: 0,
word_id: word.id.clone(),
word_id: word.id,
last_open: Utc::now(),
score: 1,
set_id: settings.id.clone(),
set_id: settings.id,
})
.collect();
@@ -383,7 +371,7 @@ impl CardSet {
pub fn next(&mut self) -> (WordData, CardStatistics) {
let index = match self.order_module.clone() {
OrderModule::SemiRandomSRS(mut module) => {
if module.initialized == false {
if !module.initialized {
module.init(self)
}
let index = module.next(self);
@@ -391,7 +379,7 @@ impl CardSet {
index
}
OrderModule::RandomSRS(mut module) => {
if module.initialized == false {
if !module.initialized {
module.init(self)
}
let index = module.next(self);
@@ -399,7 +387,7 @@ impl CardSet {
index
}
OrderModule::WorstWordsSRS(mut module) => {
if module.initialized == false {
if !module.initialized {
module.init(self)
}
let index = module.next(self);
@@ -413,7 +401,7 @@ impl CardSet {
}
pub fn open(&mut self, status: WordOpenMode) {
if let None = self.current_word_index {
if self.current_word_index.is_none() {
return;
}
let index = self.current_word_index.unwrap();