Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace lazy_static with std::sync::LazyLock #123

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 5 additions & 5 deletions src/structure.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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<Regex> =
LazyLock::new(|| Regex::new(r"^[a-z0-9_-]{1,2}$").unwrap());
static PACKAGE_NAME_REGEX: LazyLock<Regex> =
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<Vec<DirEntry>> {
Expand Down