From e934d91ba17f83330020df3711708f5cea2819fa Mon Sep 17 00:00:00 2001 From: eatradish Date: Wed, 14 May 2025 10:49:09 +0800 Subject: [PATCH 1/2] refactor: use `std::sync::LazyLock` to replace `lazy_static` Note that this modification raises the Rust version requirement to 1.80+ --- Cargo.toml | 3 +-- src/lib.rs | 16 ++++++---------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6c11e244f..994d50d61 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,6 @@ include = [ [target.'cfg(all(unix, not(target_os = "macos")))'.dependencies] dbus = { version = "0.9", optional = true } -lazy_static = { version = "1.5", optional = true } image = { version = "0.25", optional = true } zbus = { version = "5", optional = true, default-features = false } serde = { version = "1", optional = true } @@ -47,7 +46,7 @@ z-with-tokio = ["zbus", "serde", "tokio"] async = ["zbus/async-io"] tokio = ["zbus/tokio"] debug_namespace = [] -images = ["image", "lazy_static"] +images = ["image"] [dev-dependencies] color-backtrace = "0.7" # wait for MSVR 1.70 to update diff --git a/src/lib.rs b/src/lib.rs index f0af58ace..fdef19de1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -157,10 +157,6 @@ extern crate mac_notification_sys; #[cfg(target_os = "windows")] extern crate winrt_notification; -#[macro_use] -#[cfg(all(feature = "images", unix, not(target_os = "macos")))] -extern crate lazy_static; - pub mod error; mod hints; mod miniver; @@ -213,13 +209,13 @@ pub use crate::urgency::Urgency; pub use crate::{notification::Notification, timeout::Timeout}; #[cfg(all(feature = "images", unix, not(target_os = "macos")))] -lazy_static! { - /// Read once at runtime. Needed for Images - pub static ref SPEC_VERSION: miniver::Version = - get_server_information() +/// Read once at runtime. Needed for Images +pub static SPEC_VERSION: std::sync::LazyLock = std::sync::LazyLock::new(|| { + get_server_information() .and_then(|info| info.spec_version.parse::()) - .unwrap_or_else(|_| miniver::Version::new(1,1)); -} + .unwrap_or_else(|_| miniver::Version::new(1, 1)) +}); + /// Return value of `get_server_information()`. #[derive(Debug)] pub struct ServerInformation { From 7f904b7a4fa149a764263dce6500d7a5f4e511c7 Mon Sep 17 00:00:00 2001 From: Hendrik Sollich Date: Sat, 17 May 2025 11:41:42 +0200 Subject: [PATCH 2/2] build: add inert lazy_static feature to appease the semvre gods --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index 994d50d61..b3e04f7e8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,6 +47,7 @@ async = ["zbus/async-io"] tokio = ["zbus/tokio"] debug_namespace = [] images = ["image"] +lazy_static= [] # inert, here for backward compait, remove with next breaking change [dev-dependencies] color-backtrace = "0.7" # wait for MSVR 1.70 to update