Skip to content

Commit ca6cd42

Browse files
eatradishhoodie
authored andcommitted
refactor: use std::sync::LazyLock to replace lazy_static
Note that this modification raises the Rust version requirement to 1.80+
1 parent 2999946 commit ca6cd42

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ include = [
2222

2323
[target.'cfg(all(unix, not(target_os = "macos")))'.dependencies]
2424
dbus = { version = "0.9", optional = true }
25-
lazy_static = { version = "1.5", optional = true }
2625
image = { version = "0.25", optional = true }
2726
zbus = { version = "5", optional = true }
2827
serde = { version = "1", optional = true }
@@ -45,7 +44,7 @@ d_vendored = ["dbus/vendored"]
4544
z = ["zbus", "serde", "async"]
4645
async = []
4746
debug_namespace = []
48-
images = ["image", "lazy_static"]
47+
images = ["image"]
4948

5049
[dev-dependencies]
5150
color-backtrace = "0.7" # wait for MSVR 1.70 to update

src/lib.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,6 @@ extern crate mac_notification_sys;
156156
#[cfg(target_os = "windows")]
157157
extern crate winrt_notification;
158158

159-
#[macro_use]
160-
#[cfg(all(feature = "images", unix, not(target_os = "macos")))]
161-
extern crate lazy_static;
162-
163159
pub mod error;
164160
mod hints;
165161
mod miniver;
@@ -212,13 +208,13 @@ pub use crate::urgency::Urgency;
212208
pub use crate::{notification::Notification, timeout::Timeout};
213209

214210
#[cfg(all(feature = "images", unix, not(target_os = "macos")))]
215-
lazy_static! {
216-
/// Read once at runtime. Needed for Images
217-
pub static ref SPEC_VERSION: miniver::Version =
218-
get_server_information()
211+
/// Read once at runtime. Needed for Images
212+
pub static SPEC_VERSION: std::sync::LazyLock<miniver::Version> = std::sync::LazyLock::new(|| {
213+
get_server_information()
219214
.and_then(|info| info.spec_version.parse::<miniver::Version>())
220-
.unwrap_or_else(|_| miniver::Version::new(1,1));
221-
}
215+
.unwrap_or_else(|_| miniver::Version::new(1, 1))
216+
});
217+
222218
/// Return value of `get_server_information()`.
223219
#[derive(Debug)]
224220
pub struct ServerInformation {

0 commit comments

Comments
 (0)