Use std LazyLock instead of once_cell crate

This commit is contained in:
Ian Douglas Scott 2025-01-16 10:21:35 -08:00
parent b259655839
commit a428659ade
4 changed files with 7 additions and 9 deletions

1
Cargo.lock generated
View file

@ -1274,7 +1274,6 @@ dependencies = [
"libcosmic", "libcosmic",
"log", "log",
"memmap2 0.9.5", "memmap2 0.9.5",
"once_cell",
"rust-embed", "rust-embed",
"rustix 0.38.43", "rustix 0.38.43",
"tokio", "tokio",

View file

@ -21,7 +21,6 @@ memmap2 = "0.9.0"
tokio = "1.23.0" tokio = "1.23.0"
wayland-protocols = "0.32.1" wayland-protocols = "0.32.1"
zbus = { version = "4.0.0", default-features = false, features = ["tokio"] } zbus = { version = "4.0.0", default-features = false, features = ["tokio"] }
once_cell = "1.18.0"
delegate = "0.13.0" delegate = "0.13.0"
itertools = "0.14.0" itertools = "0.14.0"
log = "0.4.20" log = "0.4.20"

View file

@ -5,14 +5,14 @@ use i18n_embed::{
fluent::{fluent_language_loader, FluentLanguageLoader}, fluent::{fluent_language_loader, FluentLanguageLoader},
DefaultLocalizer, LanguageLoader, Localizer, DefaultLocalizer, LanguageLoader, Localizer,
}; };
use once_cell::sync::Lazy;
use rust_embed::RustEmbed; use rust_embed::RustEmbed;
use std::sync::LazyLock;
#[derive(RustEmbed)] #[derive(RustEmbed)]
#[folder = "i18n/"] #[folder = "i18n/"]
struct Localizations; struct Localizations;
pub static LANGUAGE_LOADER: Lazy<FluentLanguageLoader> = Lazy::new(|| { pub static LANGUAGE_LOADER: LazyLock<FluentLanguageLoader> = LazyLock::new(|| {
let loader: FluentLanguageLoader = fluent_language_loader!(); let loader: FluentLanguageLoader = fluent_language_loader!();
loader loader

View file

@ -30,13 +30,13 @@ use cosmic::{
use cosmic_comp_config::CosmicCompConfig; use cosmic_comp_config::CosmicCompConfig;
use cosmic_config::{cosmic_config_derive::CosmicConfigEntry, CosmicConfigEntry}; use cosmic_config::{cosmic_config_derive::CosmicConfigEntry, CosmicConfigEntry};
use i18n_embed::DesktopLanguageRequester; use i18n_embed::DesktopLanguageRequester;
use once_cell::sync::Lazy;
use std::{ use std::{
borrow::Cow, borrow::Cow,
collections::{HashMap, HashSet}, collections::{HashMap, HashSet},
mem, mem,
path::PathBuf, path::PathBuf,
str, str,
sync::LazyLock,
}; };
mod desktop_info; mod desktop_info;
@ -57,11 +57,11 @@ struct CosmicWorkspacesConfig {
// Include `pid` in mime. Want to drag between our surfaces, but not another // Include `pid` in mime. Want to drag between our surfaces, but not another
// process, if we use Wayland object ids. // process, if we use Wayland object ids.
#[allow(dead_code)] #[allow(dead_code)]
static WORKSPACE_MIME: Lazy<String> = static WORKSPACE_MIME: LazyLock<String> =
Lazy::new(|| format!("text/x.cosmic-workspace-id-{}", std::process::id())); LazyLock::new(|| format!("text/x.cosmic-workspace-id-{}", std::process::id()));
static TOPLEVEL_MIME: Lazy<String> = static TOPLEVEL_MIME: LazyLock<String> =
Lazy::new(|| format!("text/x.cosmic-toplevel-id-{}", std::process::id())); LazyLock::new(|| format!("text/x.cosmic-toplevel-id-{}", std::process::id()));
#[derive(Parser, Debug, Clone)] #[derive(Parser, Debug, Clone)]
#[command(author, version, about, long_about = None)] #[command(author, version, about, long_about = None)]