improve error handling in FutureMoves::get_board_from_idx

This commit is contained in:
Simon Gardling 2025-04-22 15:53:50 -04:00
parent 693b5c1f7c
commit ff7cf6cb0d
Signed by: titaniumtown
GPG Key ID: 9AB28AC10ECE533D

View File

@ -355,14 +355,14 @@ impl FutureMoves {
}
fn get_board_from_idx(&self, idx: usize) -> Option<Board> {
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)
})
}