From 61d4b7377fcd87a3174bc14582e7188aaeb54cc0 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 22 Jun 2025 02:53:21 +0300 Subject: [PATCH] colors: remove lazy_static dependency and use LazyLock for COLORS --- Cargo.lock | 7 ------- Cargo.toml | 1 - src/colors.rs | 13 ++++++------- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e65dced..c3d8d07 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -236,12 +236,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "lazy_static" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" - [[package]] name = "libc" version = "0.2.171" @@ -265,7 +259,6 @@ name = "microfetch" version = "0.4.8" dependencies = [ "criterion", - "lazy_static", "libc", "nix", ] diff --git a/Cargo.toml b/Cargo.toml index f598dce..2662682 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,6 @@ path = "src/main.rs" [dependencies] nix = { version = "0.30", features = ["fs", "hostname", "feature"] } -lazy_static = "1.5" libc = "0.2" [dev-dependencies] diff --git a/src/colors.rs b/src/colors.rs index 11a4b9f..da613a5 100644 --- a/src/colors.rs +++ b/src/colors.rs @@ -1,4 +1,5 @@ use std::env; +use std::sync::LazyLock; pub struct Colors { pub reset: &'static str, @@ -36,13 +37,11 @@ impl Colors { } } -lazy_static::lazy_static! { - pub static ref COLORS: Colors = { - // check for NO_COLOR once at startup - let is_no_color = env::var("NO_COLOR").is_ok(); - Colors::new(is_no_color) - }; -} +pub static COLORS: LazyLock = LazyLock::new(|| { + // check for NO_COLOR once at startup + let is_no_color = env::var("NO_COLOR").is_ok(); + Colors::new(is_no_color) +}); pub fn print_dots() -> String { format!(