From 963fcf7c6078273093575cbc652284b7bf7d4a97 Mon Sep 17 00:00:00 2001 From: Jonathan Schoreels Date: Wed, 30 Apr 2025 13:53:36 +0200 Subject: [PATCH] Check if self.card.reps>0 before substracing 1 (#3966) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Check if self.card.reps>0 before substracing 1 * Fix formatting * Use a more rust-y way to avoid the Panic for underflow, especially wé're talking seed value Co-Authored-By: jake --------- Co-authored-by: jake --- rslib/src/scheduler/answering/current.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rslib/src/scheduler/answering/current.rs b/rslib/src/scheduler/answering/current.rs index c40513a18..65eb87044 100644 --- a/rslib/src/scheduler/answering/current.rs +++ b/rslib/src/scheduler/answering/current.rs @@ -71,7 +71,7 @@ impl CardStateUpdater { // Decrease reps by 1 to get correct seed for fuzz. // If the fuzz calculation changes, this will break. let last_ivl_with_fuzz = self.learning_ivl_with_fuzz( - get_fuzz_seed_for_id_and_reps(self.card.id, self.card.reps - 1), + get_fuzz_seed_for_id_and_reps(self.card.id, self.card.reps.wrapping_sub(1)), last_ivl, ); let last_answered_time = due as i64 - last_ivl_with_fuzz as i64;