[board] Remove some old PlacedPiece code

This commit is contained in:
Eryn Wells 2025-05-19 16:50:44 -07:00
parent 0c1863acb9
commit 54ac88aaf7

View file

@ -1,6 +1,6 @@
// Eryn Wells <eryn@erynwells.me>
use chessfriend_core::{Piece, PlacedPiece, Square};
use chessfriend_core::{Piece, Square};
use std::iter::FromIterator;
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
@ -22,16 +22,6 @@ impl Mailbox {
pub fn remove(&mut self, square: Square) {
self.0[square as usize] = None;
}
pub fn iter(&self) -> impl Iterator<Item = PlacedPiece> {
self.0
.into_iter()
.flatten() // Remove the Nones
.zip(0u8..) // Enumerate with u8 instead of usize
.map(|(piece, index)| {
PlacedPiece::new(piece, unsafe { Square::from_index_unchecked(index) })
})
}
}
impl Default for Mailbox {
@ -46,16 +36,6 @@ impl From<[Option<Piece>; Square::NUM]> for Mailbox {
}
}
impl FromIterator<PlacedPiece> for Mailbox {
fn from_iter<T: IntoIterator<Item = PlacedPiece>>(iter: T) -> Self {
iter.into_iter()
.fold(Self::new(), |mut mailbox, placed_piece| {
mailbox.set(placed_piece.piece(), placed_piece.square);
mailbox
})
}
}
impl FromIterator<(Square, Piece)> for Mailbox {
fn from_iter<T: IntoIterator<Item = (Square, Piece)>>(iter: T) -> Self {
iter.into_iter()