Skip to content

Commit

Permalink
Replace lazy_static with std::sync::LazyLock (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
infinisil authored Nov 25, 2024
2 parents 54a1aec + 4b049a5 commit d717a83
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
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.14.0"
serde = { version = "1.0.214", 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

0 comments on commit d717a83

Please sign in to comment.