Replace lazy_static crate with LazyLock

This commit is contained in:
Emilia Allison 2025-11-22 20:56:16 -05:00
parent 495c9eaf2a
commit 58013fc176
No known key found for this signature in database
GPG Key ID: FEC1CE6360EEC9A8
3 changed files with 5 additions and 8 deletions

1
Cargo.lock generated
View File

@ -2500,7 +2500,6 @@ version = "0.5.0"
dependencies = [ dependencies = [
"csv", "csv",
"getrandom 0.2.15", "getrandom 0.2.15",
"lazy_static",
"log", "log",
"rand", "rand",
"regex", "regex",

View File

@ -14,6 +14,5 @@ serde_json = "1.0"
csv = "1.2" csv = "1.2"
getrandom = { version = "0.2", features = ["js"] } getrandom = { version = "0.2", features = ["js"] }
rand = { version = "0.8", features = ["small_rng"] } rand = { version = "0.8", features = ["small_rng"] }
lazy_static = "1.4"
serde_with = { version = "3.9.0", features = ["json"] } serde_with = { version = "3.9.0", features = ["json"] }
serde_yaml = "0.9.34" serde_yaml = "0.9.34"

View File

@ -6,9 +6,10 @@ use super::{
alternative_formats::EchoClientTransferRecord, mangle_headers::mangle_headers, alternative_formats::EchoClientTransferRecord, mangle_headers::mangle_headers,
transfer_record::TransferRecordDeserializeIntermediate, TransferRecord, transfer_record::TransferRecordDeserializeIntermediate, TransferRecord,
}; };
use lazy_static::lazy_static;
use regex::Regex; use regex::Regex;
use std::error::Error; use std::error::Error;
use std::sync::LazyLock;
pub fn transfer_to_records( pub fn transfer_to_records(
tr: &Transfer, tr: &Transfer,
@ -73,12 +74,10 @@ pub fn records_to_echo_client_csv(trs: Vec<TransferRecord>) -> Result<String, Bo
/// Converts "spreadsheet format" well identification to coordinates /// Converts "spreadsheet format" well identification to coordinates
pub fn string_well_to_pt(input: &str) -> Option<Well> { pub fn string_well_to_pt(input: &str) -> Option<Well> {
lazy_static! { static REGEX: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"([A-Z,a-z]+)(\d+)").unwrap());
static ref REGEX: Regex = Regex::new(r"([A-Z,a-z]+)(\d+)").unwrap();
// Can this be removed? // Can this be removed?
static ref REGEX_ALT: Regex = Regex::new(r"(\d+)").unwrap(); // static ref REGEX_ALT: Regex = Regex::new(r"(\d+)").unwrap();
}
if let Some(c1) = REGEX.captures(input) { if let Some(c1) = REGEX.captures(input) {
if let (Some(row), Some(col)) = (letters_to_num(&c1[1]), c1[2].parse::<u8>().ok()) { if let (Some(row), Some(col)) = (letters_to_num(&c1[1]), c1[2].parse::<u8>().ok()) {
return Some(Well { row, col }); return Some(Well { row, col });