[board] Convert a few more Piece and PlacedPiece to pass by ref

This commit is contained in:
Eryn Wells 2024-01-21 10:39:57 -08:00
parent 8835d8b40e
commit 683d89b726
2 changed files with 4 additions and 4 deletions

View file

@ -156,7 +156,7 @@ impl<'p> Builder<'p, ValidatedMove> {
if let Some(promotion) = promotion {
pieces.remove_piece(&moving_piece);
let _ = pieces
.place_piece(PlacedPiece::new(Piece::new(player, promotion), to_square));
.place_piece(&PlacedPiece::new(Piece::new(player, promotion), to_square));
} else {
pieces.move_piece(moving_piece.piece(), from_square, to_square);
}

View file

@ -74,13 +74,13 @@ impl PieceBitBoards {
self.by_color_and_shape.bitboard_for_piece_mut(piece)
}
pub(super) fn place_piece(&mut self, piece: PlacedPiece) -> Result<(), PlacePieceError> {
pub(super) fn place_piece(&mut self, piece: &PlacedPiece) -> Result<(), PlacePieceError> {
self.place_piece_with_strategy(piece, Default::default())
}
pub(super) fn place_piece_with_strategy(
&mut self,
piece: PlacedPiece,
piece: &PlacedPiece,
strategy: PlacePieceStrategy,
) -> Result<(), PlacePieceError> {
let color = piece.color();
@ -124,7 +124,7 @@ impl FromIterator<PlacedPiece> for PieceBitBoards {
let mut pieces = Self::default();
for piece in iter {
let _ = pieces.place_piece(piece);
let _ = pieces.place_piece(&piece);
}
pieces