From 8e081238f2c1040f28504d73f1189878517b8330 Mon Sep 17 00:00:00 2001 From: Jonathan Schoreels Date: Mon, 28 Apr 2025 18:04:40 +0200 Subject: [PATCH] =?UTF-8?q?Use=20a=20more=20rust-y=20way=20to=20avoid=20th?= =?UTF-8?q?e=20Panic=20for=20underflow,=20especially=20w=C3=A9're=20talkin?= =?UTF-8?q?g=20seed=20value?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: jake --- rslib/src/scheduler/answering/current.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/rslib/src/scheduler/answering/current.rs b/rslib/src/scheduler/answering/current.rs index 28ad02280..65eb87044 100644 --- a/rslib/src/scheduler/answering/current.rs +++ b/rslib/src/scheduler/answering/current.rs @@ -71,14 +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, - if self.card.reps > 0 { - self.card.reps - 1 - } else { - 0 - }, - ), + 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;