[core] Remove PlacedPiece
This has been deprecated for a while now. Finally remove it!
This commit is contained in:
		
							parent
							
								
									a7d42c6c1d
								
							
						
					
					
						commit
						ae0ae49093
					
				
					 2 changed files with 1 additions and 80 deletions
				
			
		|  | @ -10,5 +10,5 @@ mod macros; | |||
| 
 | ||||
| pub use colors::Color; | ||||
| pub use coordinates::{Direction, File, Rank, Square, Wing}; | ||||
| pub use pieces::{Piece, PlacedPiece}; | ||||
| pub use pieces::Piece; | ||||
| pub use shapes::{Shape, Slider}; | ||||
|  |  | |||
|  | @ -94,85 +94,6 @@ impl std::fmt::Display for Piece { | |||
|     } | ||||
| } | ||||
| 
 | ||||
| impl From<PlacedPiece> for Piece { | ||||
|     fn from(value: PlacedPiece) -> Self { | ||||
|         value.piece | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| impl From<&PlacedPiece> for Piece { | ||||
|     fn from(value: &PlacedPiece) -> Self { | ||||
|         value.piece | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| #[deprecated] | ||||
| #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] | ||||
| pub struct PlacedPiece { | ||||
|     pub piece: Piece, | ||||
|     pub square: Square, | ||||
| } | ||||
| 
 | ||||
| macro_rules! is_shape { | ||||
|     ($func_name:ident, $shape:ident) => { | ||||
|         #[must_use] | ||||
|         pub fn $func_name(&self) -> bool { | ||||
|             self.piece().shape == Shape::$shape | ||||
|         } | ||||
|     }; | ||||
| } | ||||
| 
 | ||||
| impl PlacedPiece { | ||||
|     #[must_use] | ||||
|     pub const fn new(piece: Piece, square: Square) -> PlacedPiece { | ||||
|         PlacedPiece { piece, square } | ||||
|     } | ||||
| 
 | ||||
|     /// The [Piece] itself
 | ||||
|     #[inline] | ||||
|     #[must_use] | ||||
|     pub fn piece(&self) -> Piece { | ||||
|         self.piece | ||||
|     } | ||||
| 
 | ||||
|     is_shape!(is_pawn, Pawn); | ||||
|     is_shape!(is_knight, Knight); | ||||
|     is_shape!(is_bishop, Bishop); | ||||
|     is_shape!(is_rook, Rook); | ||||
|     is_shape!(is_queen, Queen); | ||||
|     is_shape!(is_king, King); | ||||
| 
 | ||||
|     #[must_use] | ||||
|     pub fn is_kingside_rook(&self) -> bool { | ||||
|         self.is_rook() | ||||
|             && match self.piece.color { | ||||
|                 Color::White => self.square == Square::H1, | ||||
|                 Color::Black => self.square == Square::H8, | ||||
|             } | ||||
|     } | ||||
| 
 | ||||
|     #[must_use] | ||||
|     pub fn is_queenside_rook(&self) -> bool { | ||||
|         self.is_rook() | ||||
|             && match self.piece.color { | ||||
|                 Color::White => self.square == Square::A1, | ||||
|                 Color::Black => self.square == Square::A8, | ||||
|             } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| impl std::fmt::Display for PlacedPiece { | ||||
|     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||||
|         write!(f, "{}{}", self.piece, self.square) | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| impl From<(&Square, &Piece)> for PlacedPiece { | ||||
|     fn from(value: (&Square, &Piece)) -> Self { | ||||
|         PlacedPiece::new(*value.1, *value.0) | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| #[cfg(test)] | ||||
| mod tests { | ||||
|     use super::*; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue