Skip to content

Commit

Permalink
Use once_cell to lower MSRV
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Dec 8, 2024
1 parent d155787 commit 1034d41
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ collapsible_if = "allow"
boxcar = "0.2.6"
indexmap = "2.6.0"
itertools = "0.13.0"
once_cell = "1.20.2"
pep440_rs = { version = "0.7.2", features = ["version-ranges"] }
regex = "1.10.4"
rustc-hash = "2.0.0"
Expand Down
4 changes: 2 additions & 2 deletions src/marker/algebra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,17 @@ use std::sync::Mutex;
use std::sync::MutexGuard;

use itertools::Either;
use once_cell::sync::Lazy;
use pep440_rs::{release_specifier_to_range, Operator, Version, VersionSpecifier};
use rustc_hash::FxHashMap;
use std::sync::LazyLock;
use version_ranges::Ranges;

use crate::marker::MarkerValueExtra;
use crate::ExtraOperator;
use crate::{MarkerExpression, MarkerOperator, MarkerValueString, MarkerValueVersion};

/// The global node interner.
pub(crate) static INTERNER: LazyLock<Interner> = LazyLock::new(Interner::default);
pub(crate) static INTERNER: Lazy<Interner> = Lazy::new(Interner::default);

/// An interner for decision nodes.
///
Expand Down
8 changes: 4 additions & 4 deletions src/verbatim_url.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use once_cell::sync::Lazy;
use regex::Regex;
use std::borrow::Cow;
use std::cmp::Ordering;
use std::fmt::Debug;
use std::hash::Hash;
use std::ops::Deref;
use std::path::{Path, PathBuf};
use std::sync::LazyLock;
use thiserror::Error;
use url::{ParseError, Url};

Expand Down Expand Up @@ -325,13 +325,13 @@ pub enum VerbatimUrlError {
pub fn expand_env_vars(s: &str) -> Cow<'_, str> {
// Generate the project root, to be used via the `${PROJECT_ROOT}`
// environment variable.
static PROJECT_ROOT_FRAGMENT: LazyLock<String> = LazyLock::new(|| {
static PROJECT_ROOT_FRAGMENT: Lazy<String> = Lazy::new(|| {
let project_root = std::env::current_dir().unwrap();
project_root.to_string_lossy().to_string()
});

static RE: LazyLock<Regex> =
LazyLock::new(|| Regex::new(r"(?P<var>\$\{(?P<name>[A-Z0-9_]+)})").unwrap());
static RE: Lazy<Regex> =
Lazy::new(|| Regex::new(r"(?P<var>\$\{(?P<name>[A-Z0-9_]+)})").unwrap());

RE.replace_all(s, |caps: &regex::Captures<'_>| {
let name = caps.name("name").unwrap().as_str();
Expand Down

0 comments on commit 1034d41

Please sign in to comment.