From fc02a9e512df7ab601b4264274d4c0ad79244b9e Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Fri, 28 Feb 2025 18:10:39 -0500 Subject: [PATCH] use LazyLock instead of lazy_static --- Cargo.lock | 7 ------- Cargo.toml | 1 - src/logic/move.rs | 6 ++---- src/repr/board.rs | 9 +++------ 4 files changed, 5 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 97d5429..8350392 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -310,12 +310,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "lazy_static" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" - [[package]] name = "libc" version = "0.2.170" @@ -441,7 +435,6 @@ dependencies = [ "criterion", "either", "indicatif", - "lazy_static", "nohash-hasher", "num", "rand", diff --git a/Cargo.toml b/Cargo.toml index 0353088..f21c2cf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,6 @@ bitvec = { version = "1", optional = true } const_fn = "0.4" either = "1.13" indicatif = "0.17" -lazy_static = "1.5" nohash-hasher = "0.2" num = "0.4" rand = "0.9" diff --git a/src/logic/move.rs b/src/logic/move.rs index c8742da..5584e12 100644 --- a/src/logic/move.rs +++ b/src/logic/move.rs @@ -1,6 +1,6 @@ use super::board_value::BoardValueMap; use crate::repr::{Board, CoordPair, Piece, Winner}; -use lazy_static::lazy_static; +use std::sync::LazyLock; #[derive(Clone, Debug)] pub struct Move { @@ -35,9 +35,7 @@ pub struct Move { pub is_trimmed: bool, } -lazy_static! { - static ref BVM: BoardValueMap = BoardValueMap::new(); -} +static BVM: LazyLock = LazyLock::new(|| BoardValueMap::new()); impl Move { pub fn new(coord: Option, board: Board, color: Piece, agent_color: Piece) -> Self { diff --git a/src/repr/board.rs b/src/repr/board.rs index d0a7ae6..5792ea0 100644 --- a/src/repr/board.rs +++ b/src/repr/board.rs @@ -5,8 +5,7 @@ use super::{ CoordAxis, CoordPair, }; use const_fn::const_fn; -use lazy_static::lazy_static; -use std::{cmp::Ordering, fmt}; +use std::{cmp::Ordering, fmt, sync::LazyLock}; #[derive(PartialEq, Eq, Copy, Clone, Debug)] pub enum Winner { @@ -15,10 +14,8 @@ pub enum Winner { None, } -lazy_static! { - /// Precompute all possible chains for each position on the board - static ref ADJ_LOOKUP: PosMap = gen_adj_lookup(); -} +/// Precompute all possible chains for each position on the board +static ADJ_LOOKUP: LazyLock> = LazyLock::new(|| gen_adj_lookup()); /// Repersents a Othello game board at a certain space #[derive(Copy, Clone, PartialEq, Eq)]