From 967a6e5270f183704fb6ab0b21c3cf789cb9ad88 Mon Sep 17 00:00:00 2001 From: tiye Date: Sat, 23 Nov 2024 01:21:20 +0800 Subject: [PATCH] replace lazy_static with lazylock --- Cargo.toml | 1 - src/calx.rs | 11 ++++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 97f4b94..1f12218 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,6 @@ path = "src/bin/cli.rs" [dependencies] cirru_parser = "0.1.31" regex = "1.10.5" -lazy_static = "1.5.0" bincode = "2.0.0-rc.3" argh = "0.1.12" diff --git a/src/calx.rs b/src/calx.rs index 304aad3..2304314 100644 --- a/src/calx.rs +++ b/src/calx.rs @@ -2,9 +2,8 @@ mod types; // use bincode::{Decode, Encode}; use core::fmt; -use lazy_static::lazy_static; use regex::Regex; -use std::{rc::Rc, str::FromStr}; +use std::{rc::Rc, str::FromStr, sync::LazyLock}; pub use types::CalxType; @@ -111,8 +110,6 @@ impl fmt::Display for Calx { } } -lazy_static! { - static ref FLOAT_PATTERN: Regex = Regex::new("^-?\\d+\\.(\\d+)?$").unwrap(); - static ref INT_PATTERN: Regex = Regex::new("^-?\\d+$").unwrap(); - static ref USIZE_PATTERN: Regex = Regex::new("^\\d+$").unwrap(); -} +static FLOAT_PATTERN: LazyLock = LazyLock::new(|| Regex::new("^-?\\d+\\.(\\d+)?$").unwrap()); +static INT_PATTERN: LazyLock = LazyLock::new(|| Regex::new("^-?\\d+$").unwrap()); +// static USIZE_PATTERN: LazyLock = LazyLock::new(|| Regex::new("^\\d+$").unwrap());