colors: remove lazy_static dependency and use LazyLock for COLORS

This commit is contained in:
raf 2025-06-22 02:53:21 +03:00
commit 61d4b7377f
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
3 changed files with 6 additions and 15 deletions

7
Cargo.lock generated
View file

@ -236,12 +236,6 @@ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
[[package]]
name = "lazy_static"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.171" version = "0.2.171"
@ -265,7 +259,6 @@ name = "microfetch"
version = "0.4.8" version = "0.4.8"
dependencies = [ dependencies = [
"criterion", "criterion",
"lazy_static",
"libc", "libc",
"nix", "nix",
] ]

View file

@ -13,7 +13,6 @@ path = "src/main.rs"
[dependencies] [dependencies]
nix = { version = "0.30", features = ["fs", "hostname", "feature"] } nix = { version = "0.30", features = ["fs", "hostname", "feature"] }
lazy_static = "1.5"
libc = "0.2" libc = "0.2"
[dev-dependencies] [dev-dependencies]

View file

@ -1,4 +1,5 @@
use std::env; use std::env;
use std::sync::LazyLock;
pub struct Colors { pub struct Colors {
pub reset: &'static str, pub reset: &'static str,
@ -36,13 +37,11 @@ impl Colors {
} }
} }
lazy_static::lazy_static! { pub static COLORS: LazyLock<Colors> = LazyLock::new(|| {
pub static ref COLORS: Colors = { // check for NO_COLOR once at startup
// check for NO_COLOR once at startup let is_no_color = env::var("NO_COLOR").is_ok();
let is_no_color = env::var("NO_COLOR").is_ok(); Colors::new(is_no_color)
Colors::new(is_no_color) });
};
}
pub fn print_dots() -> String { pub fn print_dots() -> String {
format!( format!(