From 58013fc1766a8f74db56d1184bc58eb411249666 Mon Sep 17 00:00:00 2001 From: Emilia Date: Sat, 22 Nov 2025 20:56:16 -0500 Subject: [PATCH] Replace lazy_static crate with LazyLock --- Cargo.lock | 1 - plate-tool-lib/Cargo.toml | 1 - plate-tool-lib/src/csv/conversion.rs | 11 +++++------ 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index adf38b8..208e0db 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2500,7 +2500,6 @@ version = "0.5.0" dependencies = [ "csv", "getrandom 0.2.15", - "lazy_static", "log", "rand", "regex", diff --git a/plate-tool-lib/Cargo.toml b/plate-tool-lib/Cargo.toml index a0ae963..99b5636 100644 --- a/plate-tool-lib/Cargo.toml +++ b/plate-tool-lib/Cargo.toml @@ -14,6 +14,5 @@ serde_json = "1.0" csv = "1.2" getrandom = { version = "0.2", features = ["js"] } rand = { version = "0.8", features = ["small_rng"] } -lazy_static = "1.4" serde_with = { version = "3.9.0", features = ["json"] } serde_yaml = "0.9.34" diff --git a/plate-tool-lib/src/csv/conversion.rs b/plate-tool-lib/src/csv/conversion.rs index 969d989..8972a81 100644 --- a/plate-tool-lib/src/csv/conversion.rs +++ b/plate-tool-lib/src/csv/conversion.rs @@ -6,9 +6,10 @@ use super::{ alternative_formats::EchoClientTransferRecord, mangle_headers::mangle_headers, transfer_record::TransferRecordDeserializeIntermediate, TransferRecord, }; -use lazy_static::lazy_static; use regex::Regex; + use std::error::Error; +use std::sync::LazyLock; pub fn transfer_to_records( tr: &Transfer, @@ -73,12 +74,10 @@ pub fn records_to_echo_client_csv(trs: Vec) -> Result Option { - lazy_static! { - static ref REGEX: Regex = Regex::new(r"([A-Z,a-z]+)(\d+)").unwrap(); + static REGEX: LazyLock = LazyLock::new(|| Regex::new(r"([A-Z,a-z]+)(\d+)").unwrap()); - // Can this be removed? - static ref REGEX_ALT: Regex = Regex::new(r"(\d+)").unwrap(); - } + // Can this be removed? + // static ref REGEX_ALT: Regex = Regex::new(r"(\d+)").unwrap(); if let Some(c1) = REGEX.captures(input) { if let (Some(row), Some(col)) = (letters_to_num(&c1[1]), c1[2].parse::().ok()) { return Some(Well { row, col });