[bitboard, core] Make library getters const; parameterize Library attributes

- Add chessfriend_core::Color::NUM
- All the library getters can be const.
- Use the constants from the core library to define the length of the slices in
  the Library struct.
This commit is contained in:
Eryn Wells 2024-04-25 07:56:53 -07:00
parent cad040e454
commit 1b63f56042
2 changed files with 34 additions and 31 deletions

View file

@ -11,7 +11,11 @@ pub enum Color {
}
impl Color {
pub const ALL: [Color; 2] = [Color::White, Color::Black];
/// Number of colors
pub const NUM: usize = 2;
/// Slice of all possible colors
pub const ALL: [Color; Color::NUM] = [Color::White, Color::Black];
pub fn iter() -> impl Iterator<Item = &'static Color> {
Color::ALL.iter()