Skip to content

Commit

Permalink
Merge pull request #358 from jbaublitz/issue-project-698
Browse files Browse the repository at this point in the history
Change to once_cell
  • Loading branch information
jbaublitz authored Apr 29, 2024
2 parents 7580267 + f0cd372 commit 2fac7b5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ either = "1.6.1"
libc = "0.2.147"
bitflags = "2.3.1"
log = "0.4.19"
once_cell = "1.19.0"
serde_json = "1.0.0"
lazy_static = "1.4.0"

[dependencies.uuid]
version = "1.0.0"
Expand Down
10 changes: 4 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ mod status;
mod tests;
mod wipe;

use once_cell::sync::Lazy;

#[cfg(cryptsetup23supported)]
pub use crate::mem::{SafeBorrowedMemZero, SafeMemzero, SafeOwnedMemZero};
pub use crate::{
Expand Down Expand Up @@ -78,14 +80,10 @@ pub use libc::{c_int, c_uint, size_t};
pub type Result<T> = std::result::Result<T, LibcryptErr>;

#[cfg(feature = "mutex")]
lazy_static::lazy_static! {
static ref MUTEX: crate::mutex::PerThreadMutex = crate::mutex::PerThreadMutex::default();
}
static MUTEX: Lazy<crate::mutex::PerThreadMutex> = Lazy::new(crate::mutex::PerThreadMutex::default);

#[cfg(not(feature = "mutex"))]
lazy_static::lazy_static! {
static ref THREAD_ID: std::thread::ThreadId = std::thread::current().id();
}
static THREAD_ID: Lazy<std::thread::ThreadId> = Lazy::new(|| std::thread::current().id());

#[cfg(test)]
mod test {
Expand Down

0 comments on commit 2fac7b5

Please sign in to comment.