[board, position] Return replaced piece when placing a piece with PlacePieceStrategy::Replace

When place_piece() is called with PlacePieceStrategy::Replace, return the replaced
piece in the Ok() variant of the Result as an Option<Piece>.

Plumb this new return type through Board and Position.
This commit is contained in:
Eryn Wells 2025-06-02 15:54:00 -07:00
parent 09fbe1be22
commit cae93cb090
3 changed files with 7 additions and 5 deletions

View file

@ -59,7 +59,7 @@ impl Position {
piece: Piece,
square: Square,
strategy: PlacePieceStrategy,
) -> Result<(), PlacePieceError> {
) -> Result<Option<Piece>, PlacePieceError> {
self.board.place_piece(piece, square, strategy)
}