Formating with fmt

This commit is contained in:
2026-08-19 23:51:41 +03:00
parent de2dbaf6c1
commit bf805b79e5
13 changed files with 44 additions and 42 deletions
+3 -2
View File
@@ -1,5 +1,5 @@
use crate::lang::{CardStatistics, DeckSettings}; use crate::lang::{CardStatistics, DeckSettings};
use rusqlite::{params, Connection}; use rusqlite::{Connection, params};
use std::time::Instant; use std::time::Instant;
pub fn load_stats_of_deck(set: &DeckSettings, connection: &Connection) -> Vec<CardStatistics> { pub fn load_stats_of_deck(set: &DeckSettings, connection: &Connection) -> Vec<CardStatistics> {
@@ -78,5 +78,6 @@ pub fn delete_stat(stat: &CardStatistics, connection: &Connection) {
return; return;
} }
connection connection
.execute("DELETE FROM card_stats WHERE id = ?1", (&stat.id,)).unwrap(); .execute("DELETE FROM card_stats WHERE id = ?1", (&stat.id,))
.unwrap();
} }
+1 -2
View File
@@ -1,5 +1,5 @@
use crate::lang::{WordData, WordGroup}; use crate::lang::{WordData, WordGroup};
use rusqlite::{params, Connection}; use rusqlite::{Connection, params};
use std::collections::HashMap; use std::collections::HashMap;
pub fn add_word(word: &mut WordData, connection: &Connection) { pub fn add_word(word: &mut WordData, connection: &Connection) {
@@ -45,7 +45,6 @@ pub fn add_words(words: &mut [WordData], connection: &mut Connection) {
let last_index: u32 = tx.last_insert_rowid() as u32; let last_index: u32 = tx.last_insert_rowid() as u32;
tx.commit().unwrap(); tx.commit().unwrap();
let start_index = last_index - (count as u32) + 1; let start_index = last_index - (count as u32) + 1;
for (index, id) in (start_index..=last_index).enumerate() { for (index, id) in (start_index..=last_index).enumerate() {
+2 -5
View File
@@ -600,13 +600,10 @@ impl DictionaryState {
fn add_word_button(&self) -> iced::Element<'_, DictionaryMessage> { fn add_word_button(&self) -> iced::Element<'_, DictionaryMessage> {
let state = self.state.lock().unwrap(); let state = self.state.lock().unwrap();
let group_id = state.word_groups[self.selected_group_index].id; let group_id = state.word_groups[self.selected_group_index].id;
let button = button("Добавить слово") let button = button("Добавить слово").style(jl_button);
.style(jl_button);
if group_id.is_valid() { if group_id.is_valid() {
return return button.on_press(NewWord).into();
button.on_press(NewWord)
.into();
} }
button.into() button.into()
+2 -5
View File
@@ -171,11 +171,8 @@ impl DictionaryQuizState {
self.is_help = false; self.is_help = false;
self.answer = String::new(); self.answer = String::new();
let next : WordData = let next: WordData = match self.current_set.pop() {
match self.current_set.pop() { Some(word) => word,
Some(word) => {
word
}
None => { None => {
self.update_set(); self.update_set();
self.current_set.pop().expect("Empty set") self.current_set.pop().expect("Empty set")
+8 -4
View File
@@ -1,15 +1,15 @@
use crate::data_provider::import::{get_words_of_group, load_groups, ImportData, ImportGroup}; use crate::AppState;
use crate::data_provider::import::{ImportData, ImportGroup, get_words_of_group, load_groups};
use crate::data_provider::words::{add_group, add_words}; use crate::data_provider::words::{add_group, add_words};
use crate::dictionary::app_data_dir; use crate::dictionary::app_data_dir;
use crate::import::ImportMessage::*; use crate::import::ImportMessage::*;
use crate::lang::{WordData, WordGroup}; use crate::lang::{WordData, WordGroup};
use crate::navigation::{NavigatedPage, Page, RootMessage}; use crate::navigation::{NavigatedPage, Page, RootMessage};
use crate::styling::*; use crate::styling::*;
use crate::AppState;
use iced::widget::button::danger; use iced::widget::button::danger;
use iced::widget::container::success; use iced::widget::container::success;
use iced::widget::{ use iced::widget::{
button, checkbox, column, container, progress_bar, row, rule, text, text_input, Row, Row, button, checkbox, column, container, progress_bar, row, rule, text, text_input,
}; };
use iced::widget::{scrollable, space}; use iced::widget::{scrollable, space};
use iced::{Element, Task}; use iced::{Element, Task};
@@ -512,7 +512,11 @@ impl ImportState {
.map(|name| (name.clone(), Vec::<usize>::with_capacity(1))) .map(|name| (name.clone(), Vec::<usize>::with_capacity(1)))
.collect::<Vec<_>>(); .collect::<Vec<_>>();
for (key, endpoint) in &group.mapping { for (key, endpoint) in &group.mapping {
let property_index = group.fields.iter().position(|f| f == key).expect("Unknown property"); let property_index = group
.fields
.iter()
.position(|f| f == key)
.expect("Unknown property");
let group_index = result let group_index = result
.iter() .iter()
.position(|(name, _)| name == endpoint) .position(|(name, _)| name == endpoint)
+1 -3
View File
@@ -588,9 +588,7 @@ impl SRSModule for WorstWordsSRSModule {
} }
match self.queue.pop() { match self.queue.pop() {
Some(index) => { Some(index) => index,
index
}
None => { None => {
self.queue.append(&mut self.pool.clone()); self.queue.append(&mut self.pool.clone());
self.rounds_remaining -= 1; self.rounds_remaining -= 1;
+2 -2
View File
@@ -31,10 +31,10 @@ use iced::{Font, window};
use iced::{Subscription, Theme, keyboard}; use iced::{Subscription, Theme, keyboard};
use iced_core::Size; use iced_core::Size;
use iced_core::window::Position; use iced_core::window::Position;
use mimalloc::MiMalloc;
use rusqlite::Connection;
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
use iced_core::window::settings::PlatformSpecific; use iced_core::window::settings::PlatformSpecific;
use mimalloc::MiMalloc;
use rusqlite::Connection;
#[global_allocator] #[global_allocator]
static GLOBAL: MiMalloc = MiMalloc; static GLOBAL: MiMalloc = MiMalloc;
+2 -2
View File
@@ -3,7 +3,7 @@ use crate::data_provider::sqlite::{create_db, default_connection};
use crate::data_provider::web_api::{ use crate::data_provider::web_api::{
get_local_version, get_web_version, load_data, set_local_version, get_local_version, get_web_version, load_data, set_local_version,
}; };
use crate::dictionary::{app_data_dir, DictionaryMessage, DictionaryState}; use crate::dictionary::{DictionaryMessage, DictionaryState, app_data_dir};
use crate::dictionary_test::{DictionaryQuizMessage, DictionaryQuizState}; use crate::dictionary_test::{DictionaryQuizMessage, DictionaryQuizState};
use crate::history::{HistoryMessage, HistoryState}; use crate::history::{HistoryMessage, HistoryState};
use crate::import::{ImportMessage, ImportState}; use crate::import::{ImportMessage, ImportState};
@@ -23,7 +23,7 @@ use crate::sync::{SyncMessage, SyncState};
use crate::view_navigation; use crate::view_navigation;
use crate::word::{WordMessage, WordState}; use crate::word::{WordMessage, WordState};
use crate::writing::{WritingMessage, WritingState}; use crate::writing::{WritingMessage, WritingState};
use crate::{fill_state, AppState}; use crate::{AppState, fill_state};
use chrono::NaiveDate; use chrono::NaiveDate;
use hashbrown::HashMap; use hashbrown::HashMap;
use iced::keyboard::Event; use iced::keyboard::Event;
+1 -1
View File
@@ -54,7 +54,7 @@ impl NavigatedPage<QuizMessage> for QuizState {
self.update_showed() self.update_showed()
} }
} }
Back => {}, Back => {}
} }
Task::none() Task::none()
} }
+6 -4
View File
@@ -6,13 +6,13 @@ use crate::navigation::{NavigatedPage, Page, RootMessage};
use crate::repetition_settings::RepetitionSettingsMessage::*; use crate::repetition_settings::RepetitionSettingsMessage::*;
use crate::styling::*; use crate::styling::*;
use iced::widget::button::danger; use iced::widget::button::danger;
use iced::widget::text_input::Catalog;
use iced::widget::{button, column, row, scrollable, space, text, text_input}; use iced::widget::{button, column, row, scrollable, space, text, text_input};
use iced::{Element, Task}; use iced::{Element, Task};
use iced_core::Length::Fill; use iced_core::Length::Fill;
use iced_core::{color, Padding, Theme}; use iced_core::{Padding, Theme, color};
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use std::time::Duration; use std::time::Duration;
use iced::widget::text_input::Catalog;
pub struct RepetitionSettingsState { pub struct RepetitionSettingsState {
set: DeckSettings, set: DeckSettings,
@@ -117,13 +117,15 @@ impl NavigatedPage<RepetitionSettingsMessage> for RepetitionSettingsState {
.spacing(QUARTER_SPACING), .spacing(QUARTER_SPACING),
column![ column![
text!("Фильтр"), text!("Фильтр"),
text_input("", &self.set.filter).style(|x, status| { text_input("", &self.set.filter)
.style(|x, status| {
let mut primary = Theme::default()(x, status); let mut primary = Theme::default()(x, status);
if !self.correct_filter { if !self.correct_filter {
primary.border.color = color!(255, 255, 0); primary.border.color = color!(255, 255, 0);
} }
primary primary
}).on_input(SetFilter), })
.on_input(SetFilter),
button("Проверить фильтр") button("Проверить фильтр")
.style(jl_button) .style(jl_button)
.on_press(TryFilter), .on_press(TryFilter),
+5 -1
View File
@@ -577,7 +577,11 @@ impl RepetitionsState {
.cloned(); .cloned();
Self::append_words(state, deck, required); Self::append_words(state, deck, required);
} }
fn append_words(state: &mut AppState, deck: &DeckSettings, indices: impl Iterator<Item = usize>) { fn append_words(
state: &mut AppState,
deck: &DeckSettings,
indices: impl Iterator<Item = usize>,
) {
let words = &state.dictionary; let words = &state.dictionary;
let stats = &mut indices let stats = &mut indices
.map(|i| { .map(|i| {
+1 -1
View File
@@ -30,7 +30,7 @@ impl NavigatedPage<WritingMessage> for WritingState {
fn navigated(&mut self) {} fn navigated(&mut self) {}
fn update(&mut self, message: WritingMessage) -> Task<RootMessage> { fn update(&mut self, message: WritingMessage) -> Task<RootMessage> {
match message { match message {
WritingMessage::Back => {}, WritingMessage::Back => {}
WritingMessage::Next => self.next(), WritingMessage::Next => self.next(),
WritingMessage::SwitchShowMode(b) => self.show_all = b, WritingMessage::SwitchShowMode(b) => self.show_all = b,
} }