diff --git a/Cargo.lock b/Cargo.lock index 0fc349f..dae522a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1519,7 +1519,6 @@ dependencies = [ "icu_provider 1.5.0", "indexmap", "itertools 0.14.0", - "lazy_static", "libcosmic", "log", "open", diff --git a/Cargo.toml b/Cargo.toml index 9af8c1d..8c0beff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,6 @@ hex_color = { version = "3", features = ["serde"] } indexmap = "2" #TODO: for repeat_n, which is in std in 1.82 itertools = "0.14" -lazy_static = "1" log = "0.4" open = "5.3.2" palette = { version = "0.7", features = ["serde"] } diff --git a/src/localize.rs b/src/localize.rs index cabd298..0d5e9ef 100644 --- a/src/localize.rs +++ b/src/localize.rs @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-only -use std::str::FromStr; +use std::{str::FromStr, sync::LazyLock}; use i18n_embed::{ fluent::{fluent_language_loader, FluentLanguageLoader}, @@ -14,20 +14,17 @@ use rust_embed::RustEmbed; #[folder = "i18n/"] struct Localizations; -lazy_static::lazy_static! { - pub static ref LANGUAGE_LOADER: FluentLanguageLoader = { - let loader: FluentLanguageLoader = fluent_language_loader!(); +pub static LANGUAGE_LOADER: LazyLock = LazyLock::new(|| { + let loader: FluentLanguageLoader = fluent_language_loader!(); - loader - .load_fallback_language(&Localizations) - .expect("Error while loading fallback language"); + loader + .load_fallback_language(&Localizations) + .expect("Error while loading fallback language"); - loader - }; -} + loader +}); -lazy_static::lazy_static! { - pub static ref LANGUAGE_SORTER: Collator = { +pub static LANGUAGE_SORTER: LazyLock = LazyLock::new(|| { let mut options = CollatorOptions::new(); options.numeric = Some(Numeric::On); @@ -40,8 +37,7 @@ lazy_static::lazy_static! { Collator::try_new(&locale, options).ok() }) .expect("Creating a collator from the system's current language, the fallback language, or American English should succeed") - }; -} +}); #[macro_export] macro_rules! fl { diff --git a/src/main.rs b/src/main.rs index 35dac07..0bd1fb0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -33,9 +33,11 @@ use std::{ any::TypeId, cmp, collections::{BTreeMap, BTreeSet, HashMap}, - env, fs, process, + env, + error::Error, + fs, process, rc::Rc, - sync::{atomic::Ordering, Mutex}, + sync::{atomic::Ordering, LazyLock, Mutex}, }; use tokio::sync::mpsc; @@ -71,11 +73,7 @@ mod dnd; use clap_lex::RawArgs; -use std::error::Error; - -lazy_static::lazy_static! { - static ref ICON_CACHE: Mutex = Mutex::new(IconCache::new()); -} +static ICON_CACHE: LazyLock> = LazyLock::new(|| Mutex::new(IconCache::new())); pub fn icon_cache_get(name: &'static str, size: u16) -> widget::icon::Icon { let mut icon_cache = ICON_CACHE.lock().unwrap();