diff --git a/src/sync.rs b/src/sync.rs index 7c5fc7b..b611969 100644 --- a/src/sync.rs +++ b/src/sync.rs @@ -910,6 +910,10 @@ impl LazyMap { init: f, } } + + pub fn clear(&mut self) { + self.map.clear(); + } } impl LazyMap @@ -957,6 +961,19 @@ where } } +impl LazyMap +where + K: Eq + Hash, + S: BuildHasher, +{ + pub fn remove(&mut self, key: &Q) -> Option + where + Q: Hash + Equivalent + ?Sized, + { + self.map.remove(key) + } +} + impl core::ops::Index<&Q> for LazyMap where K: Eq + Hash, diff --git a/src/unsync.rs b/src/unsync.rs index 9d52649..1fa0ba1 100644 --- a/src/unsync.rs +++ b/src/unsync.rs @@ -475,6 +475,10 @@ impl LazyMap { init: f, } } + + pub fn clear(&mut self) { + self.map.clear(); + } } impl LazyMap @@ -522,6 +526,19 @@ where } } +impl LazyMap +where + K: Eq + Hash, + S: BuildHasher, +{ + pub fn remove(&mut self, key: &Q) -> Option + where + Q: Hash + Equivalent + ?Sized, + { + self.map.remove(key) + } +} + /// Creates a `LazyMap` that fills all values with `V::default()`. impl Default for LazyMap { fn default() -> Self {