Statically assert zero-cost invariants

Since some or all of those invariants will come in handy to ensure we
use as little memory as possible, to maximize the speed of the move
generation later on.
This commit is contained in:
Bruno BELANYI 2022-07-18 11:05:38 +02:00
parent accbbef64e
commit a6f4e7e686
4 changed files with 17 additions and 0 deletions

View file

@ -1,4 +1,5 @@
use super::{Bitboard, File, Rank};
use crate::utils::static_assert;
/// Represent a square on a chessboard. Defined in the same order as the
/// [Bitboard](crate::board::Bitboard) squares.
@ -185,6 +186,9 @@ impl std::ops::Sub<Bitboard> for Square {
}
}
// Ensure that niche-optimization is in effect.
static_assert!(std::mem::size_of::<Option<Square>>() == std::mem::size_of::<Square>());
#[cfg(test)]
mod test {
use super::*;