From 2011ae001bfae73ee73e828e8e5e7141a8275dd7 Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Thu, 20 Feb 2025 19:33:15 -0500 Subject: [PATCH] cleanup --- Cargo.lock | 33 +++++---------------------------- Cargo.toml | 3 +-- src/repr/bitboard.rs | 8 ++------ src/repr/board.rs | 18 +++--------------- 4 files changed, 11 insertions(+), 51 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 80badea..0801c46 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -129,17 +129,6 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" -[[package]] -name = "comptime" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed5e683f1f8879ac923fa7f69d180872f9bb8a417505c332f08fa6955f537dd2" -dependencies = [ - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "console" version = "0.15.10" @@ -442,7 +431,6 @@ version = "0.1.0" dependencies = [ "arrayvec", "bitvec", - "comptime", "const_fn", "criterion", "either", @@ -638,7 +626,7 @@ checksum = "5a9bf7cf98d04a2b28aead066b7496853d4779c9cc183c440dbac457641e19a0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn", ] [[package]] @@ -659,17 +647,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "syn" -version = "1.0.109" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - [[package]] name = "syn" version = "2.0.98" @@ -750,7 +727,7 @@ dependencies = [ "log", "proc-macro2", "quote", - "syn 2.0.98", + "syn", "wasm-bindgen-shared", ] @@ -772,7 +749,7 @@ checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -933,7 +910,7 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn", ] [[package]] @@ -944,5 +921,5 @@ checksum = "76331675d372f91bf8d17e13afbd5fe639200b73d01f0fc748bb059f9cca2db7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.98", + "syn", ] diff --git a/Cargo.toml b/Cargo.toml index 62f7bb5..fc83ed9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,8 +29,7 @@ bitvec = [ "dep:bitvec" ] [dependencies] arrayvec = "0.7" bitvec = { version = "1", optional = true } -comptime = "1.0.0" -const_fn = "0.4.11" +const_fn = "0.4" either = "1.13" indicatif = "0.17" lazy_static = "1.5" diff --git a/src/repr/bitboard.rs b/src/repr/bitboard.rs index 5e6e31f..83e5573 100644 --- a/src/repr/bitboard.rs +++ b/src/repr/bitboard.rs @@ -26,19 +26,15 @@ pub struct BitBoard(BitBoardInner); // BitBoard should be big enough to fit all points on the board const_assert!(std::mem::size_of::() * 8 >= Board::BOARD_AREA); -impl Default for BitBoard { - fn default() -> Self { - Self::new() - } -} - impl BitBoard { #[cfg(feature = "bitvec")] + #[allow(clippy::new_without_default)] pub const fn new() -> Self { Self(bitarr!(BBBaseType, Lsb0; 0; Board::BOARD_AREA)) } #[cfg(not(feature = "bitvec"))] + #[allow(clippy::new_without_default)] pub const fn new() -> Self { Self(0) } diff --git a/src/repr/board.rs b/src/repr/board.rs index 76d2298..df65a2d 100644 --- a/src/repr/board.rs +++ b/src/repr/board.rs @@ -14,24 +14,17 @@ type Chain = ArrayVec<(usize, usize), { Board::BOARD_SIZE - 1 }>; /// A collection of chains (up vert, down vert, left horiz, right horiz, diagonals....) type ChainCollection = ArrayVec; -const BOARD_AREA: usize = Board::BOARD_AREA; - /// Map of all points on the board against some type T /// Used to index like so: example[i][j] /// with each coordinate -pub struct PosMap(ArrayVec); - -impl Default for PosMap { - fn default() -> Self { - Self::new() - } -} +pub struct PosMap(ArrayVec); impl PosMap { const fn index(row: usize, col: usize) -> usize { row * Board::BOARD_SIZE + col } + #[allow(clippy::new_without_default)] pub fn new() -> Self { Self(ArrayVec::from_iter( (0..Board::BOARD_AREA).map(|_| Default::default()), @@ -186,12 +179,6 @@ impl fmt::Debug for Board { } } -impl Default for Board { - fn default() -> Self { - Self::new() - } -} - impl Board { pub const BOARD_SIZE: usize = 8; @@ -199,6 +186,7 @@ impl Board { pub const BOARD_AREA: usize = Self::BOARD_SIZE.pow(2); /// Create a new empty board + #[allow(clippy::new_without_default)] pub const fn new() -> Self { Self { white_board: BitBoard::new(),