From ff7cf6cb0d38a9a21c1c2ecff5fdb499ba2ab621 Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Tue, 22 Apr 2025 15:53:50 -0400 Subject: [PATCH] improve error handling in FutureMoves::get_board_from_idx --- src/logic/future_moves.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/logic/future_moves.rs b/src/logic/future_moves.rs index d76b640..fa3efd9 100644 --- a/src/logic/future_moves.rs +++ b/src/logic/future_moves.rs @@ -355,14 +355,14 @@ impl FutureMoves { } fn get_board_from_idx(&self, idx: usize) -> Option { - self.move_history(idx).map(|hist| { + self.move_history(idx).and_then(|hist| { let mut board = self.board; for (m, c) in hist { if let Some(m) = m { - board.place(m, c).expect("move would not propegate"); + board.place(m, c).ok()?; } } - board + Some(board) }) }