Skip to content

Commit

Permalink
Change once_cell::Lazy to std::cell::LazyCell (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
yozhgoor authored Dec 7, 2024
1 parent 82052cc commit 6ff0cf1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
3 changes: 1 addition & 2 deletions 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 @@ -22,7 +22,6 @@ serde = { version = "1", features = ["derive"] }
tempfile = "3.10"
toml = "0.8"
regex = "1.10"
once_cell = "1.19"

[target.'cfg(unix)'.dependencies]
libc = "0.2"
Expand Down
8 changes: 3 additions & 5 deletions src/dependency.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::{bail, Result};
use once_cell::sync::Lazy;
use regex::Regex;
use std::sync::LazyLock;

#[derive(Debug, PartialEq, Eq, Clone)]
pub enum Dependency {
Expand All @@ -19,11 +19,9 @@ pub enum Dependency {
}

pub fn parse_dependency(s: &str) -> Result<Dependency> {
// This will change when `std::lazy` is released.
// See https://github.com/rust-lang/rust/issues/74465.
static RE: Lazy<Regex> = Lazy::new(|| {
static RE: LazyLock<Regex> = LazyLock::new(|| {
Regex::new(r"^((?P<name>[^+=/]+)=)?(?P<version>((?P<url>\w+://([^:@]+(:[^@]+)?@)?[^#+]*?(?P<url_end>/[^#+/]+)?)(#branch=(?P<branch>[^+]+)|#rev=(?P<rev>[^+]+))?)|[^+]+)?(?P<features>(\+[^+]+)*)$")
.unwrap()
.expect("dependency's regex must be compiled")
});

match RE.captures(s) {
Expand Down

0 comments on commit 6ff0cf1

Please sign in to comment.