Drop once_cell dependency (#14198)

This PR drops the `once_cell` dependency from all Nu crates, replacing
uses of the
[`Lazy`](https://docs.rs/once_cell/latest/once_cell/sync/struct.Lazy.html)
type with its `std` equivalent,
[`LazyLock`](https://doc.rust-lang.org/std/sync/struct.LazyLock.html).
This commit is contained in:
Alex Ionescu
2024-10-29 17:33:46 +01:00
committed by GitHub
parent 74bd0e32cc
commit e104bccfb9
19 changed files with 44 additions and 53 deletions

View File

@ -19,7 +19,6 @@ nu-utils = { path = "../nu-utils", version = "0.99.2" }
nu-engine = { path = "../nu-engine", version = "0.99.2" }
nu-color-config = { path = "../nu-color-config", version = "0.99.2" }
nu-ansi-term = { workspace = true }
once_cell = { workspace = true }
fancy-regex = { workspace = true }
tabled = { workspace = true, features = ["ansi"], default-features = false }
terminal_size = { workspace = true }

View File

@ -91,12 +91,14 @@ fn colorize_lead_trail_space(
fn colorize_space_one(text: &str, lead: Option<ANSIStr<'_>>, trail: Option<ANSIStr<'_>>) -> String {
use fancy_regex::Captures;
use fancy_regex::Regex;
use once_cell::sync::Lazy;
use std::sync::LazyLock;
static RE_LEADING: Lazy<Regex> =
Lazy::new(|| Regex::new(r"(?m)(?P<beginsp>^\s+)").expect("error with leading space regex"));
static RE_TRAILING: Lazy<Regex> =
Lazy::new(|| Regex::new(r"(?m)(?P<endsp>\s+$)").expect("error with trailing space regex"));
static RE_LEADING: LazyLock<Regex> = LazyLock::new(|| {
Regex::new(r"(?m)(?P<beginsp>^\s+)").expect("error with leading space regex")
});
static RE_TRAILING: LazyLock<Regex> = LazyLock::new(|| {
Regex::new(r"(?m)(?P<endsp>\s+$)").expect("error with trailing space regex")
});
let mut buf = text.to_owned();