Final code cleanup

This commit is contained in:
2026-08-20 00:42:06 +03:00
parent ac1b516a88
commit 3661173bb0
3 changed files with 47 additions and 48 deletions
+9 -11
View File
@@ -1,9 +1,10 @@
use crate::AppState;
use crate::data_provider::card_stats::{delete_stat, load_stats_of_deck, update_stat_score}; use crate::data_provider::card_stats::{delete_stat, load_stats_of_deck, update_stat_score};
use crate::data_provider::history::{HistoryItem, push_note}; use crate::data_provider::history::{push_note, HistoryItem};
use crate::AppState;
use chrono::{DateTime, Utc}; use chrono::{DateTime, Utc};
use rand::distr::Distribution; use parking_lot::Mutex;
use rand::distr::weighted::WeightedIndex; use rand::distr::weighted::WeightedIndex;
use rand::distr::Distribution;
use rand::prelude::SliceRandom; use rand::prelude::SliceRandom;
use rand::rng; use rand::rng;
use rand::rngs::ThreadRng; use rand::rngs::ThreadRng;
@@ -11,15 +12,14 @@ use rayon::iter::IndexedParallelIterator;
use rayon::iter::IntoParallelRefIterator; use rayon::iter::IntoParallelRefIterator;
use rayon::iter::ParallelIterator; use rayon::iter::ParallelIterator;
use rhai::{Engine, Scope}; use rhai::{Engine, Scope};
use rusqlite::ToSql;
use rusqlite::types::{FromSql, FromSqlError, FromSqlResult, ToSqlOutput, ValueRef}; use rusqlite::types::{FromSql, FromSqlError, FromSqlResult, ToSqlOutput, ValueRef};
use rusqlite::ToSql;
use std::cmp::PartialEq; use std::cmp::PartialEq;
use std::collections::HashMap; use std::collections::HashMap;
use std::fmt::{Display, Formatter}; use std::fmt::{Display, Formatter};
use std::num::ParseIntError; use std::num::ParseIntError;
use std::str::FromStr; use std::str::FromStr;
use std::sync::Arc; use std::sync::Arc;
use parking_lot::Mutex;
use std::time::Instant; use std::time::Instant;
const MAX_HISTORY_LEN: usize = 20; const MAX_HISTORY_LEN: usize = 20;
@@ -668,12 +668,7 @@ impl DeckSettings {
let engine = Engine::new(); let engine = Engine::new();
let ast = engine.compile(&self.filter); let ast = engine.compile(&self.filter);
if ast.is_err() { if let Ok(ast) = ast {
return list;
}
let ast = ast.unwrap();
let groups = &state.word_groups; let groups = &state.word_groups;
list = state list = state
@@ -711,6 +706,9 @@ impl DeckSettings {
println!("Collecting available words is {:?}", time.elapsed()); println!("Collecting available words is {:?}", time.elapsed());
list list
} else {
list
}
} }
pub fn require_speech(&self) -> bool { pub fn require_speech(&self) -> bool {
self.forward == "speech" || self.backward == "speech" self.forward == "speech" || self.backward == "speech"
+1
View File
@@ -56,6 +56,7 @@ fn main() -> iced::Result {
.run() .run()
} }
#[allow(unused_mut)]
fn window_settings() -> window::Settings { fn window_settings() -> window::Settings {
let mut settings = window::Settings { let mut settings = window::Settings {
position: Position::Centered, position: Position::Centered,
+1 -1
View File
@@ -132,7 +132,7 @@ impl ScreenState {
Ok(v) => v, Ok(v) => v,
}; };
let id: Id = history_file_name[4..history_file_name.len() - 12] let id = history_file_name[4..history_file_name.len() - 12]
.parse::<Id>() .parse::<Id>()
.unwrap(); .unwrap();