diff --git a/CHANGELOG.md b/CHANGELOG.md index 78a3845..c55bbe8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,12 +4,19 @@ All notable changes to this project will be documented in this file. ## Unreleased +### Improvements + +* `OnceMap` no longer requires `K: Clone` everywhere. + ## [0.6.2] - 2026-01-21 ### New features * Implement `once::OnceMap` to run computation only once and store the results in a hash map. * `singleflight::Group` now supports custom hashers for keys. + +### Improvements + * `singleflight::Group::forget` now accepts any `&Q` where `Q: ?Sized + Hash + Eq` and `K: Borrow` aligning with standard HashMap's interface. ## [0.6.1] - 2026-01-11 diff --git a/mea/src/once/once_map/mod.rs b/mea/src/once/once_map/mod.rs index b4087f1..e3f1179 100644 --- a/mea/src/once/once_map/mod.rs +++ b/mea/src/once/once_map/mod.rs @@ -36,7 +36,7 @@ pub struct OnceMap { impl Default for OnceMap where - K: Eq + Hash + Clone, + K: Eq + Hash, V: Clone, S: BuildHasher + Clone + Default, { @@ -47,7 +47,7 @@ where impl OnceMap where - K: Eq + Hash + Clone, + K: Eq + Hash, V: Clone, { /// Creates a new OnceMap with the default hasher. @@ -67,7 +67,7 @@ where impl OnceMap where - K: Eq + Hash + Clone, + K: Eq + Hash, V: Clone, S: BuildHasher + Clone, { @@ -96,7 +96,7 @@ where // 1. Get or create the OnceCell. let cell = { let mut map = self.map.lock(); - map.entry(key.clone()) + map.entry(key) .or_insert_with(|| Arc::new(OnceCell::new())) .clone() }; @@ -121,7 +121,7 @@ where // 1. Get or create the OnceCell. let cell = { let mut map = self.map.lock(); - map.entry(key.clone()) + map.entry(key) .or_insert_with(|| Arc::new(OnceCell::new())) .clone() };