From 4b049a5b772d3679850ec180b1f9ef3266fc85c8 Mon Sep 17 00:00:00 2001 From: Will Bush Date: Wed, 30 Oct 2024 02:15:12 -0500 Subject: [PATCH] Replace lazy_static with std::sync::LazyLock lazy_static is no longer needed. We can just use this from std: https://doc.rust-lang.org/std/sync/struct.LazyLock.html --- Cargo.lock | 1 - Cargo.toml | 1 - src/structure.rs | 10 +++++----- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5ff71b0..16bc064 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -302,7 +302,6 @@ dependencies = [ "derive_more", "indoc", "itertools", - "lazy_static", "pretty_assertions", "regex", "relative-path", diff --git a/Cargo.toml b/Cargo.toml index 81a2bcf..cf60d09 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,6 @@ serde_json = "1.0.132" tempfile = "3.13.0" serde = { version = "1.0.213", features = ["derive"] } anyhow = "1.0" -lazy_static = "1.5.0" colored = "2.1.0" itertools = "0.13.0" rowan = "0.15.16" diff --git a/src/structure.rs b/src/structure.rs index 93b5975..b294858 100644 --- a/src/structure.rs +++ b/src/structure.rs @@ -1,9 +1,9 @@ use std::fs::DirEntry; use std::path::Path; +use std::sync::LazyLock; use anyhow::Context; use itertools::{concat, process_results}; -use lazy_static::lazy_static; use regex::Regex; use relative_path::RelativePathBuf; @@ -15,10 +15,10 @@ use crate::NixFileStore; pub const BASE_SUBPATH: &str = "pkgs/by-name"; pub const PACKAGE_NIX_FILENAME: &str = "package.nix"; -lazy_static! { - static ref SHARD_NAME_REGEX: Regex = Regex::new(r"^[a-z0-9_-]{1,2}$").unwrap(); - static ref PACKAGE_NAME_REGEX: Regex = Regex::new(r"^[a-zA-Z0-9_-]+$").unwrap(); -} +static SHARD_NAME_REGEX: LazyLock = + LazyLock::new(|| Regex::new(r"^[a-z0-9_-]{1,2}$").unwrap()); +static PACKAGE_NAME_REGEX: LazyLock = + LazyLock::new(|| Regex::new(r"^[a-zA-Z0-9_-]+$").unwrap()); /// Deterministic file listing so that tests are reproducible. pub fn read_dir_sorted(base_dir: &Path) -> anyhow::Result> {