improve error handling in FutureMoves::get_board_from_idx
This commit is contained in:
parent
693b5c1f7c
commit
ff7cf6cb0d
@ -355,14 +355,14 @@ impl FutureMoves {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_board_from_idx(&self, idx: usize) -> Option<Board> {
|
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;
|
let mut board = self.board;
|
||||||
for (m, c) in hist {
|
for (m, c) in hist {
|
||||||
if let Some(m) = m {
|
if let Some(m) = m {
|
||||||
board.place(m, c).expect("move would not propegate");
|
board.place(m, c).ok()?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
board
|
Some(board)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user