[board] Move piece! and position! macros to a new macros.rs module
This commit is contained in:
parent
e56b3259e2
commit
2269df2ed9
5 changed files with 22 additions and 21 deletions
20
board/src/macros.rs
Normal file
20
board/src/macros.rs
Normal file
|
@ -0,0 +1,20 @@
|
|||
// 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()
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue