[board] Remove the unused Mailbox::new method
Just use Mailbox::default().
This commit is contained in:
parent
7f25548335
commit
a91bb8c983
1 changed files with 2 additions and 6 deletions
|
@ -7,10 +7,6 @@ use std::iter::FromIterator;
|
||||||
pub(crate) struct Mailbox([Option<Piece>; Square::NUM]);
|
pub(crate) struct Mailbox([Option<Piece>; Square::NUM]);
|
||||||
|
|
||||||
impl Mailbox {
|
impl Mailbox {
|
||||||
pub fn new() -> Self {
|
|
||||||
Self::default()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get(&self, square: Square) -> Option<Piece> {
|
pub fn get(&self, square: Square) -> Option<Piece> {
|
||||||
self.0[square as usize]
|
self.0[square as usize]
|
||||||
}
|
}
|
||||||
|
@ -46,7 +42,7 @@ impl From<[Option<Piece>; Square::NUM]> for Mailbox {
|
||||||
impl FromIterator<(Square, Piece)> for Mailbox {
|
impl FromIterator<(Square, Piece)> for Mailbox {
|
||||||
fn from_iter<T: IntoIterator<Item = (Square, Piece)>>(iter: T) -> Self {
|
fn from_iter<T: IntoIterator<Item = (Square, Piece)>>(iter: T) -> Self {
|
||||||
iter.into_iter()
|
iter.into_iter()
|
||||||
.fold(Self::new(), |mut mailbox, (square, piece)| {
|
.fold(Self::default(), |mut mailbox, (square, piece)| {
|
||||||
mailbox.set(piece, square);
|
mailbox.set(piece, square);
|
||||||
mailbox
|
mailbox
|
||||||
})
|
})
|
||||||
|
@ -61,7 +57,7 @@ mod tests {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn iter_returns_all_pieces() {
|
fn iter_returns_all_pieces() {
|
||||||
let mut mailbox = Mailbox::new();
|
let mut mailbox = Mailbox::default();
|
||||||
mailbox.set(piece!(White Queen), Square::C3);
|
mailbox.set(piece!(White Queen), Square::C3);
|
||||||
mailbox.set(piece!(White Rook), Square::H8);
|
mailbox.set(piece!(White Rook), Square::H8);
|
||||||
mailbox.set(piece!(Black Bishop), Square::E4);
|
mailbox.set(piece!(Black Bishop), Square::E4);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue