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

Use once_cell to lower MSRV #22

Merged
merged 2 commits into from
Jan 2, 2025
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: 1 addition & 0 deletions 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
4 changes: 2 additions & 2 deletions src/marker/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1344,7 +1344,7 @@ pub struct MarkerTreeDebugGraph<'a> {
marker: &'a MarkerTree,
}

impl<'a> fmt::Debug for MarkerTreeDebugGraph<'a> {
impl fmt::Debug for MarkerTreeDebugGraph<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.marker.fmt_graph(f, 0)
}
Expand All @@ -1361,7 +1361,7 @@ pub struct MarkerTreeDebugRaw<'a> {
marker: &'a MarkerTree,
}

impl<'a> fmt::Debug for MarkerTreeDebugRaw<'a> {
impl fmt::Debug for MarkerTreeDebugRaw<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let node = INTERNER.shared.node(self.marker.0);
f.debug_tuple("MarkerTreeDebugRaw").field(node).finish()
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
Loading