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",
]
[[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",
]

View file

@ -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]

View file

@ -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<Colors> = 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!(