diff --git a/Cargo.lock b/Cargo.lock index 33ebf92a3..52b0d5572 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5589,7 +5589,6 @@ dependencies = [ "hex", "image", "k9", - "lazy_static", "libc", "log", "memmem", @@ -6547,7 +6546,6 @@ version = "0.3.0" dependencies = [ "csscolorparser", "deltae", - "lazy_static", "serde", "wezterm-dynamic", ] @@ -6723,7 +6721,6 @@ version = "0.1.0" dependencies = [ "bitflags 1.3.2", "euclid", - "lazy_static", "serde", "wezterm-dynamic", ] diff --git a/color-types/Cargo.toml b/color-types/Cargo.toml index 1c62db6e2..1237e1f61 100644 --- a/color-types/Cargo.toml +++ b/color-types/Cargo.toml @@ -13,6 +13,5 @@ use_serde = ["serde"] [dependencies] csscolorparser = {workspace=true, features=["lab"]} deltae.workspace = true -lazy_static.workspace = true serde = {workspace=true, features = ["derive"], optional=true} wezterm-dynamic.workspace = true diff --git a/color-types/src/lib.rs b/color-types/src/lib.rs index bd12a1ae3..8c5385797 100644 --- a/color-types/src/lib.rs +++ b/color-types/src/lib.rs @@ -4,14 +4,13 @@ use serde::{Deserialize, Serialize}; use std::collections::HashMap; use std::hash::{Hash, Hasher}; use std::str::FromStr; +use std::sync::LazyLock; use wezterm_dynamic::{FromDynamic, FromDynamicOptions, ToDynamic, Value}; -lazy_static::lazy_static! { - static ref SRGB_TO_F32_TABLE: [f32;256] = generate_srgb8_to_linear_f32_table(); - static ref F32_TO_U8_TABLE: [u32;104] = generate_linear_f32_to_srgb8_table(); - static ref RGB_TO_SRGB_TABLE: [u8;256] = generate_rgb_to_srgb8_table(); - static ref RGB_TO_F32_TABLE: [f32;256] = generate_rgb_to_linear_f32_table(); -} +static SRGB_TO_F32_TABLE: LazyLock<[f32; 256]> = LazyLock::new(generate_srgb8_to_linear_f32_table); +static F32_TO_U8_TABLE: LazyLock<[u32; 104]> = LazyLock::new(generate_linear_f32_to_srgb8_table); +static RGB_TO_SRGB_TABLE: LazyLock<[u8; 256]> = LazyLock::new(generate_rgb_to_srgb8_table); +static RGB_TO_F32_TABLE: LazyLock<[f32; 256]> = LazyLock::new(generate_rgb_to_linear_f32_table); fn generate_rgb_to_srgb8_table() -> [u8; 256] { let mut table = [0; 256]; @@ -330,9 +329,7 @@ impl From for SrgbaTuple { } } -lazy_static::lazy_static! { - static ref NAMED_COLORS: HashMap = build_colors(); -} +static NAMED_COLORS: LazyLock> = LazyLock::new(build_colors); fn build_colors() -> HashMap { let mut map = HashMap::new(); diff --git a/termwiz/Cargo.toml b/termwiz/Cargo.toml index 1230bf0ac..51f6b0efd 100644 --- a/termwiz/Cargo.toml +++ b/termwiz/Cargo.toml @@ -22,7 +22,6 @@ fixedbitset.workspace = true fnv = {workspace=true, optional=true} hex.workspace = true image = {workspace=true, optional=true} -lazy_static.workspace = true libc.workspace = true log.workspace = true memmem.workspace = true diff --git a/termwiz/src/escape/osc.rs b/termwiz/src/escape/osc.rs index a21f7637e..5218222ce 100644 --- a/termwiz/src/escape/osc.rs +++ b/termwiz/src/escape/osc.rs @@ -10,6 +10,7 @@ use std::collections::HashMap; use std::fmt::{Display, Error as FmtError, Formatter, Result as FmtResult}; use std::str; use std::str::FromStr; +use std::sync::LazyLock; #[derive(Debug, Clone, PartialEq)] pub enum ColorOrQuery { @@ -483,9 +484,7 @@ struct OscMap { variant_to_code: HashMap, } -lazy_static::lazy_static! { - static ref OSC_MAP: OscMap = OscMap::new(); -} +static OSC_MAP: LazyLock = LazyLock::new(OscMap::new); impl OperatingSystemCommandCode { fn from_code(code: &str) -> Option { diff --git a/termwiz/src/nerdfonts.rs b/termwiz/src/nerdfonts.rs index bd67a0487..585a92f6c 100644 --- a/termwiz/src/nerdfonts.rs +++ b/termwiz/src/nerdfonts.rs @@ -1,8 +1,7 @@ use std::collections::HashMap; +use std::sync::LazyLock; -lazy_static::lazy_static! { - pub static ref NERD_FONTS: HashMap<&'static str, char> = build_map(); -} +pub static NERD_FONTS: LazyLock> = LazyLock::new(build_map); pub use crate::nerdfonts_data::NERD_FONT_GLYPHS; diff --git a/wezterm-input-types/Cargo.toml b/wezterm-input-types/Cargo.toml index a90005362..c223aa4ce 100644 --- a/wezterm-input-types/Cargo.toml +++ b/wezterm-input-types/Cargo.toml @@ -12,7 +12,6 @@ license = "MIT" [dependencies] bitflags.workspace = true euclid.workspace = true -lazy_static.workspace = true serde = {workspace=true, features = ["rc", "derive"], optional=true} wezterm-dynamic.workspace = true diff --git a/wezterm-input-types/src/lib.rs b/wezterm-input-types/src/lib.rs index 9f93dc9ec..93383b014 100644 --- a/wezterm-input-types/src/lib.rs +++ b/wezterm-input-types/src/lib.rs @@ -5,7 +5,7 @@ use std::collections::HashMap; use std::convert::TryFrom; use std::fmt::Write; use std::sync::atomic::AtomicBool; -use std::sync::Arc; +use std::sync::{Arc, LazyLock}; use wezterm_dynamic::{FromDynamic, ToDynamic}; pub struct PixelUnit; @@ -1141,10 +1141,10 @@ impl PhysKeyCode { } } -lazy_static::lazy_static! { - static ref PHYSKEYCODE_MAP: HashMap = PhysKeyCode::make_map(); - static ref INV_PHYSKEYCODE_MAP: HashMap = PhysKeyCode::make_inv_map(); -} +static PHYSKEYCODE_MAP: LazyLock> = + LazyLock::new(PhysKeyCode::make_map); +static INV_PHYSKEYCODE_MAP: LazyLock> = + LazyLock::new(PhysKeyCode::make_inv_map); impl TryFrom<&str> for PhysKeyCode { type Error = String;