chessfriend/board/src/macros.rs

21 lines
606 B
Rust
Raw Normal View History

// Eryn Wells <eryn@erynwells.me>
#[macro_export]
macro_rules! piece {
($color:ident $shape:ident) => {
$crate::piece::Piece::new($crate::piece::Color::$color, $crate::piece::Shape::$shape)
};
($color:ident $shape:ident on $square:ident) => {
$crate::piece::PlacedPiece::new(piece!($color $shape), $crate::square::Square::$square)
}
}
#[macro_export]
macro_rules! position {
[$($color:ident $shape:ident on $square:ident),* $(,)?] => {
$crate::PositionBuilder::new()
$(.place_piece(piece!($color $shape on $square)))*
.build()
};
}