Skip to content

Commit 60b30c6

Browse files
authored
Drop dependency on once_cell (#11)
1 parent 0f1c936 commit 60b30c6

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ testing = []
4040

4141
[dependencies]
4242
comemo-macros = { workspace = true }
43-
once_cell = { workspace = true }
4443
parking_lot = { workspace = true }
4544
siphasher = { workspace = true }
4645

src/cache.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::collections::HashMap;
2+
use std::sync::LazyLock;
23
use std::sync::atomic::{AtomicUsize, Ordering};
34

4-
use once_cell::sync::Lazy;
55
use parking_lot::RwLock;
66
use siphasher::sip128::{Hasher128, SipHasher13};
77

@@ -130,7 +130,7 @@ pub fn last_was_hit() -> bool {
130130
}
131131

132132
/// A cache for a single memoized function.
133-
pub struct Cache<C, Out>(Lazy<RwLock<CacheData<C, Out>>>);
133+
pub struct Cache<C, Out>(LazyLock<RwLock<CacheData<C, Out>>>);
134134

135135
impl<C: 'static, Out: 'static> Cache<C, Out> {
136136
/// Create an empty cache.
@@ -139,7 +139,7 @@ impl<C: 'static, Out: 'static> Cache<C, Out> {
139139
/// pointer cannot be passed as an argument otherwise the function
140140
/// passed to `Lazy::new` is a closure and not a function pointer.
141141
pub const fn new(init: fn() -> RwLock<CacheData<C, Out>>) -> Self {
142-
Self(Lazy::new(init))
142+
Self(LazyLock::new(init))
143143
}
144144

145145
/// Evict all entries whose age is larger than or equal to `max_age`.

0 commit comments

Comments
 (0)