From 51a821d041c9372798c8baefd566fd5bb8819948 Mon Sep 17 00:00:00 2001 From: mulhern Date: Wed, 10 Dec 2025 17:48:53 -0500 Subject: [PATCH] Use std::sync::LazyLock instead of once_cell::Lazy Generally better to use the library standard facility rather than an external crate where possible. LazyLock was introduced in version 1.80.0 of the Rust standard library. Signed-off-by: mulhern --- Cargo.toml | 1 - src/lib.rs | 9 ++++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c563c631..9020dbf2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,6 @@ either = "1.6.1" libc = "0.2.155" bitflags = "2.3.1" log = "0.4.20" -once_cell = "1.19.0" per-thread-mutex = "0.1.4" serde_json = "1.0.0" diff --git a/src/lib.rs b/src/lib.rs index b3bdc865..f5df7a5f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -38,8 +38,6 @@ mod status; mod tests; mod wipe; -use once_cell::sync::Lazy; - #[cfg(cryptsetup23supported)] pub use crate::mem::{SafeBorrowedMemZero, SafeMemzero, SafeOwnedMemZero}; pub use crate::{ @@ -78,11 +76,12 @@ pub use libc::{c_int, c_uint, size_t}; pub type Result = std::result::Result; #[cfg(feature = "mutex")] -static MUTEX: Lazy = - Lazy::new(per_thread_mutex::PerThreadMutex::default); +static MUTEX: std::sync::LazyLock = + std::sync::LazyLock::new(per_thread_mutex::PerThreadMutex::default); #[cfg(not(feature = "mutex"))] -static THREAD_ID: Lazy = Lazy::new(|| std::thread::current().id()); +static THREAD_ID: std::sync::LazyLock = + std::sync::LazyLock::new(|| std::thread::current().id()); #[cfg(test)] mod test {