[bitboard] Fix some warnings and clippy suggestions in library.rs

- Add allow(dead_code) to LIGHT_SQUARES and DARK_SQUARES. These aren't used yet
  but I have a feeling they'll come in handy.
- Add some separators to long numeric literals.
- Lightly reformat BitBoard -> Bitboard in the module documentation
This commit is contained in:
Eryn Wells 2024-04-25 07:23:59 -07:00
parent 1f3c90ff35
commit cad040e454

View file

@ -1,12 +1,12 @@
// Eryn Wells <eryn@erynwells.me> // Eryn Wells <eryn@erynwells.me>
//! # The BitBoard Library //! # The Bitboard Library
//! //!
//! This module implements a collection of commonly used BitBoards that can be //! This module implements a collection of commonly used bitboards that can be
//! looked up efficiently as needed. //! looked up efficiently as needed.
//! //!
//! The `library()` method returns a static instance of a `Library`, which //! The `library()` method returns a static instance of a `Library`, which
//! provides getters for all available BitBoards. //! provides getters for all available bitboards.
use crate::BitBoard; use crate::BitBoard;
use chessfriend_core::{Color, Direction, Square}; use chessfriend_core::{Color, Direction, Square};
@ -28,29 +28,35 @@ pub(crate) const RANKS: [BitBoard; 8] = [
#[allow(clippy::identity_op)] #[allow(clippy::identity_op)]
#[allow(clippy::erasing_op)] #[allow(clippy::erasing_op)]
pub(crate) const FILES: [BitBoard; 8] = [ pub(crate) const FILES: [BitBoard; 8] = [
BitBoard(0x0101010101010101 << 0), BitBoard(0x0101_0101_0101_0101 << 0),
BitBoard(0x0101010101010101 << 1), BitBoard(0x0101_0101_0101_0101 << 1),
BitBoard(0x0101010101010101 << 2), BitBoard(0x0101_0101_0101_0101 << 2),
BitBoard(0x0101010101010101 << 3), BitBoard(0x0101_0101_0101_0101 << 3),
BitBoard(0x0101010101010101 << 4), BitBoard(0x0101_0101_0101_0101 << 4),
BitBoard(0x0101010101010101 << 5), BitBoard(0x0101_0101_0101_0101 << 5),
BitBoard(0x0101010101010101 << 6), BitBoard(0x0101_0101_0101_0101 << 6),
BitBoard(0x0101010101010101 << 7), BitBoard(0x0101_0101_0101_0101 << 7),
]; ];
/// Bitboards representing the kingside of the board, per color. /// Bitboards representing the kingside of the board, per color.
pub(crate) const KINGSIDES: [BitBoard; 2] = pub(crate) const KINGSIDES: [BitBoard; 2] = [
[BitBoard(0xF0F0F0F0F0F0F0F0), BitBoard(0x0F0F0F0F0F0F0F0F)]; BitBoard(0xF0F0_F0F0_F0F0_F0F0),
BitBoard(0x0F0F_0F0F_0F0F_0F0F),
];
/// Bitboards representing the queenside of the board, per color. /// Bitboards representing the queenside of the board, per color.
pub(crate) const QUEENSIDES: [BitBoard; 2] = pub(crate) const QUEENSIDES: [BitBoard; 2] = [
[BitBoard(0x0F0F0F0F0F0F0F0F), BitBoard(0xF0F0F0F0F0F0F0F0)]; BitBoard(0x0F0F_0F0F_0F0F_0F0F),
BitBoard(0xF0F0_F0F0_F0F0_F0F0),
];
/// A bitboard representing the light squares. /// A bitboard representing the light squares.
#[allow(dead_code)]
pub(crate) const LIGHT_SQUARES: BitBoard = pub(crate) const LIGHT_SQUARES: BitBoard =
BitBoard(0x5555 | 0x5555 << 16 | 0x5555 << 32 | 0x5555 << 48); BitBoard(0x5555 | 0x5555 << 16 | 0x5555 << 32 | 0x5555 << 48);
/// A bitboad representing the dark squares /// A bitboad representing the dark squares
#[allow(dead_code)]
pub(crate) const DARK_SQUARES: BitBoard = BitBoard(!LIGHT_SQUARES.0); pub(crate) const DARK_SQUARES: BitBoard = BitBoard(!LIGHT_SQUARES.0);
pub(super) fn library() -> &'static MoveLibrary { pub(super) fn library() -> &'static MoveLibrary {