From 132fea911cb51505e7100ade209a53a8e36753a0 Mon Sep 17 00:00:00 2001 From: funman300 Date: Sun, 17 May 2026 21:20:26 -0700 Subject: [PATCH] refactor(core): use saturating_add for move_count increments (M-19) recycle_count already used saturating_add(1); move_count was inconsistently using += 1 at all three call sites. No real-world overflow risk (u32 at ~4 billion moves), but the inconsistency was a code smell flagged by the review. Co-Authored-By: Claude Sonnet 4.6 --- solitaire_core/src/game_state.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/solitaire_core/src/game_state.rs b/solitaire_core/src/game_state.rs index ea6bd5e..4ba0bcf 100644 --- a/solitaire_core/src/game_state.rs +++ b/solitaire_core/src/game_state.rs @@ -247,7 +247,7 @@ impl GameState { stock.cards.push(card); } self.recycle_count = self.recycle_count.saturating_add(1); - self.move_count += 1; + self.move_count = self.move_count.saturating_add(1); return Ok(()); } @@ -273,7 +273,7 @@ impl GameState { waste.cards.push(card); } - self.move_count += 1; + self.move_count = self.move_count.saturating_add(1); Ok(()) } @@ -381,7 +381,7 @@ impl GameState { self.piles.get_mut(&to).ok_or(MoveError::InvalidDestination)?.cards.append(&mut moved); self.score = (self.score + score_delta).max(0); - self.move_count += 1; + self.move_count = self.move_count.saturating_add(1); self.is_won = self.check_win(); if !self.is_won {