Compare commits
No commits in common. "66e5109157c9189722031c93dd0c62791f6f0b91" and "74d2a2cf6aef3aea71efb979f99d2b612ec3b826" have entirely different histories.
66e5109157
...
74d2a2cf6a
|
@ -144,8 +144,6 @@
|
||||||
seer = naersk-lib.buildPackage {
|
seer = naersk-lib.buildPackage {
|
||||||
src = self;
|
src = self;
|
||||||
|
|
||||||
doCheck = true;
|
|
||||||
|
|
||||||
passthru = {
|
passthru = {
|
||||||
inherit my-rust;
|
inherit my-rust;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
use super::Square;
|
use super::Square;
|
||||||
use crate::utils::static_assert;
|
|
||||||
|
|
||||||
mod iterator;
|
mod iterator;
|
||||||
use iterator::*;
|
use iterator::*;
|
||||||
|
|
||||||
|
@ -65,9 +63,6 @@ impl Bitboard {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure zero-cost (at least size-wise) wrapping.
|
|
||||||
static_assert!(std::mem::size_of::<Bitboard>() == std::mem::size_of::<u64>());
|
|
||||||
|
|
||||||
impl Default for Bitboard {
|
impl Default for Bitboard {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::EMPTY
|
Self::EMPTY
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use super::Bitboard;
|
use super::Bitboard;
|
||||||
use crate::utils::static_assert;
|
|
||||||
|
|
||||||
/// An enum representing a singular file on a chess board (i.e: the columns).
|
/// An enum representing a singular file on a chess board (i.e: the columns).
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
|
@ -71,9 +70,6 @@ impl File {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that niche-optimization is in effect.
|
|
||||||
static_assert!(std::mem::size_of::<Option<File>>() == std::mem::size_of::<File>());
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use super::Bitboard;
|
use super::Bitboard;
|
||||||
use crate::utils::static_assert;
|
|
||||||
|
|
||||||
/// An enum representing a singular rank on a chess board (i.e: the rows).
|
/// An enum representing a singular rank on a chess board (i.e: the rows).
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
|
@ -71,9 +70,6 @@ impl Rank {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that niche-optimization is in effect.
|
|
||||||
static_assert!(std::mem::size_of::<Option<Rank>>() == std::mem::size_of::<Rank>());
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use super::{Bitboard, File, Rank};
|
use super::{Bitboard, File, Rank};
|
||||||
use crate::utils::static_assert;
|
|
||||||
|
|
||||||
/// Represent a square on a chessboard. Defined in the same order as the
|
/// Represent a square on a chessboard. Defined in the same order as the
|
||||||
/// [Bitboard](crate::board::Bitboard) squares.
|
/// [Bitboard](crate::board::Bitboard) squares.
|
||||||
|
@ -180,9 +179,6 @@ 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)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
pub mod board;
|
pub mod board;
|
||||||
pub mod utils;
|
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
pub mod static_assert;
|
|
||||||
pub use static_assert::*;
|
|
|
@ -1,28 +0,0 @@
|
||||||
//! Static assert.
|
|
||||||
|
|
||||||
/// Assert a condition at compile-time.
|
|
||||||
///
|
|
||||||
/// See [RFC 2790] for potential addition into Rust itself.
|
|
||||||
///
|
|
||||||
/// [RFC 2790]: https://github.com/rust-lang/rfcs/issues/2790
|
|
||||||
///
|
|
||||||
/// # Examples
|
|
||||||
///
|
|
||||||
/// ```
|
|
||||||
/// use seer::utils::static_assert;
|
|
||||||
///
|
|
||||||
/// static_assert!(42 > 0);
|
|
||||||
/// ```
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! static_assert {
|
|
||||||
($condition:expr) => {
|
|
||||||
// Based on the latest one in `rustc`'s one before it was [removed].
|
|
||||||
//
|
|
||||||
// [removed]: https://github.com/rust-lang/rust/commit/c2dad1c6b9f9636198d7c561b47a2974f5103f6d
|
|
||||||
#[allow(dead_code)]
|
|
||||||
const _: () = [()][!($condition) as usize];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// I want it namespaced, even though it is exported to the root of the crate by `#[macro_export]`.
|
|
||||||
pub use static_assert;
|
|
Loading…
Reference in a new issue