From 3dda17f8aafbd33cf4e7fa8595479a75173d66f9 Mon Sep 17 00:00:00 2001 From: Asuka Minato Date: Sat, 30 Nov 2024 11:33:30 +0900 Subject: [PATCH 01/10] to 2024 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 22ae027..fe68415 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rs-fsrs" version = "1.2.1" -edition = "2021" +edition = "2024" license-file = "LICENSE" description = "Rust-based Scheduler for FSRS" From 90cdcee8a579003a7cef69bfa765e6c0a2e63b4d Mon Sep 17 00:00:00 2001 From: Asuka Minato Date: Sat, 30 Nov 2024 11:40:05 +0900 Subject: [PATCH 02/10] Update check.sh --- .github/workflows/check.sh | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/.github/workflows/check.sh b/.github/workflows/check.sh index 8c45e10..9a1248c 100755 --- a/.github/workflows/check.sh +++ b/.github/workflows/check.sh @@ -2,19 +2,13 @@ set -eux -o pipefail -cargo fmt --check || ( - printf " -Please run 'cargo fmt' to format the code. -" - exit 1 -) +rustup default nightly -cargo clippy -- -D clippy::nursery || ( - printf " -run 'cargo clippy -- -D clippy::nursery' to check the code. -" - exit 1 -) +rustup update + +cargo fmt --check + +cargo clippy -- -D clippy::nursery cargo install cargo-llvm-cov --locked SKIP_TRAINING=1 cargo llvm-cov --release From 288bb100bd72150c2ae6700bc1de6ed5815ff507 Mon Sep 17 00:00:00 2001 From: Asuka Minato Date: Sat, 30 Nov 2024 11:42:35 +0900 Subject: [PATCH 03/10] Update check.sh --- .github/workflows/check.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/check.sh b/.github/workflows/check.sh index 9a1248c..98b785a 100755 --- a/.github/workflows/check.sh +++ b/.github/workflows/check.sh @@ -6,6 +6,8 @@ rustup default nightly rustup update +rustup component add rustfmt + cargo fmt --check cargo clippy -- -D clippy::nursery From 86217fcd0fd4bbab9b95fef7b957dbf9c41b07c6 Mon Sep 17 00:00:00 2001 From: Asuka Minato Date: Sat, 30 Nov 2024 11:44:20 +0900 Subject: [PATCH 04/10] r#gen --- src/tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests.rs b/src/tests.rs index a403319..03c27f5 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -204,7 +204,7 @@ fn test_alea_int32() { #[test] fn test_alea_import_state() { let mut rng = rand::thread_rng(); - let mut prng_1 = alea(Seed::new(rng.gen::())); + let mut prng_1 = alea(Seed::new(rng.r#gen::())); prng_1.gen_next(); prng_1.gen_next(); prng_1.gen_next(); From a3338d20f057bae6c8a3ad38e723a244855defaa Mon Sep 17 00:00:00 2001 From: Asuka Minato Date: Sat, 30 Nov 2024 02:51:10 +0000 Subject: [PATCH 05/10] cargo fmt --- src/algo.rs | 2 +- src/lib.rs | 2 +- src/parameters.rs | 2 +- src/scheduler.rs | 4 ++-- src/scheduler_basic.rs | 2 +- src/tests.rs | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/algo.rs b/src/algo.rs index beb7a4e..ff30443 100644 --- a/src/algo.rs +++ b/src/algo.rs @@ -1,8 +1,8 @@ +use crate::ImplScheduler; use crate::models::{Card, Rating, RecordLog, SchedulingInfo}; use crate::parameters::Parameters; use crate::scheduler_basic::BasicScheduler; use crate::scheduler_longterm::LongtermScheduler; -use crate::ImplScheduler; use chrono::{DateTime, Utc}; diff --git a/src/lib.rs b/src/lib.rs index 74a3845..904bb77 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,7 +3,7 @@ mod algo; pub use algo::FSRS; mod alea; -pub use alea::{alea, Alea, AleaState, Prng}; +pub use alea::{Alea, AleaState, Prng, alea}; mod scheduler; pub use scheduler::{ImplScheduler, Scheduler}; diff --git a/src/parameters.rs b/src/parameters.rs index 536f2b6..d1d523f 100644 --- a/src/parameters.rs +++ b/src/parameters.rs @@ -1,7 +1,7 @@ use chrono::Utc; -use crate::alea; use crate::Rating; +use crate::alea; type Weights = [f64; 19]; const DEFAULT_WEIGHTS: Weights = [ diff --git a/src/scheduler.rs b/src/scheduler.rs index e5ebdde..5a4db31 100644 --- a/src/scheduler.rs +++ b/src/scheduler.rs @@ -1,10 +1,10 @@ use chrono::{DateTime, Utc}; -use crate::models::State::*; use crate::Seed; +use crate::models::State::*; use crate::{ - models::{RecordLog, SchedulingInfo}, Card, Parameters, Rating, ReviewLog, + models::{RecordLog, SchedulingInfo}, }; #[derive(Debug, Clone)] diff --git a/src/scheduler_basic.rs b/src/scheduler_basic.rs index f8acade..46b1f90 100644 --- a/src/scheduler_basic.rs +++ b/src/scheduler_basic.rs @@ -1,6 +1,6 @@ use chrono::{DateTime, Duration, Utc}; -use crate::{scheduler::Scheduler, Card, ImplScheduler, Parameters, Rating, SchedulingInfo}; +use crate::{Card, ImplScheduler, Parameters, Rating, SchedulingInfo, scheduler::Scheduler}; use crate::{Rating::*, State::*}; pub struct BasicScheduler { pub scheduler: Scheduler, diff --git a/src/tests.rs b/src/tests.rs index 03c27f5..fc5ea29 100644 --- a/src/tests.rs +++ b/src/tests.rs @@ -1,7 +1,7 @@ #[cfg(test)] use { crate::{ - alea::{alea, AleaState}, + alea::{AleaState, alea}, algo::FSRS, models::{Card, Rating, State}, parameters::{Parameters, Seed}, From 0d595280ef32fb79ee846e820302ff341d1af70c Mon Sep 17 00:00:00 2001 From: Asuka Minato Date: Sat, 30 Nov 2024 02:54:27 +0000 Subject: [PATCH 06/10] const fn --- .github/workflows/check.sh | 1 + src/parameters.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/check.sh b/.github/workflows/check.sh index 98b785a..4b0d037 100755 --- a/.github/workflows/check.sh +++ b/.github/workflows/check.sh @@ -7,6 +7,7 @@ rustup default nightly rustup update rustup component add rustfmt +rustup component add clippy cargo fmt --check diff --git a/src/parameters.rs b/src/parameters.rs index d1d523f..5b78545 100644 --- a/src/parameters.rs +++ b/src/parameters.rs @@ -36,7 +36,7 @@ impl Parameters { (self.w[4] - f64::exp(self.w[5] * (rating_int as f64 - 1.0)) + 1.0).clamp(1.0, 10.0) } - pub fn init_stability(&self, rating: Rating) -> f64 { + pub const fn init_stability(&self, rating: Rating) -> f64 { let rating_int: i32 = rating as i32; self.w[(rating_int - 1) as usize].max(0.1) } From 020fa5c0cc1e4c0c7b2de1b5a53d95fee2edaf96 Mon Sep 17 00:00:00 2001 From: Asuka Minato Date: Sat, 30 Nov 2024 21:03:45 +0900 Subject: [PATCH 07/10] use default --- .github/workflows/check.sh | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/.github/workflows/check.sh b/.github/workflows/check.sh index 4b0d037..03715fb 100755 --- a/.github/workflows/check.sh +++ b/.github/workflows/check.sh @@ -2,16 +2,9 @@ set -eux -o pipefail -rustup default nightly +cargo +nightly fmt --check -rustup update - -rustup component add rustfmt -rustup component add clippy - -cargo fmt --check - -cargo clippy -- -D clippy::nursery +cargo +nightly clippy -- -D clippy::nursery cargo install cargo-llvm-cov --locked SKIP_TRAINING=1 cargo llvm-cov --release From f5805824b15513f43208e973fd0e6649c6d96aff Mon Sep 17 00:00:00 2001 From: Asuka Minato Date: Sun, 1 Dec 2024 20:38:01 +0900 Subject: [PATCH 08/10] use back stable --- .github/workflows/check.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/check.sh b/.github/workflows/check.sh index 03715fb..3b17eb8 100755 --- a/.github/workflows/check.sh +++ b/.github/workflows/check.sh @@ -2,9 +2,7 @@ set -eux -o pipefail -cargo +nightly fmt --check - -cargo +nightly clippy -- -D clippy::nursery +cargo fmt --check cargo install cargo-llvm-cov --locked SKIP_TRAINING=1 cargo llvm-cov --release From c678906ffaf8a6915148fe907005728e0b62ca3d Mon Sep 17 00:00:00 2001 From: Asuka Minato Date: Sun, 1 Dec 2024 20:38:20 +0900 Subject: [PATCH 09/10] 2021 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index fe68415..22ae027 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rs-fsrs" version = "1.2.1" -edition = "2024" +edition = "2021" license-file = "LICENSE" description = "Rust-based Scheduler for FSRS" From 8eefe4cb285ad8ee393b9c35930fa10e72859fca Mon Sep 17 00:00:00 2001 From: Asuka Minato Date: Sun, 1 Dec 2024 20:39:37 +0900 Subject: [PATCH 10/10] try all --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 904bb77..84800f0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -#![deny(warnings)] +#![deny(clippy::all)] mod algo; pub use algo::FSRS;