From d5c8be6213ca85d7e3ccbcc1eb5b95651ce7e253 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joel=20Wejdenst=C3=A5l?= Date: Mon, 24 Jun 2024 15:45:42 +0200 Subject: [PATCH] add shrink_to_fit test --- src/lib.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 1b0225a5..ad2b321a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -667,6 +667,19 @@ impl<'a, K: 'a + Eq + Hash, V: 'a, S: BuildHasher + Clone> DashMap { /// Remove excess capacity to reduce memory usage. /// /// **Locking behaviour:** May deadlock if called when holding any sort of reference into the map. + /// # Examples + /// + /// ``` + /// use dashmap::DashMap; + /// use dashmap::try_result::TryResult; + /// + /// let map = DashMap::new(); + /// map.insert("Johnny", 21); + /// assert!(map.capacity() > 0); + /// map.remove("Johnny"); + /// map.shrink_to_fit(); + /// assert_eq!(map.capacity(), 0); + /// ``` pub fn shrink_to_fit(&self) { self._shrink_to_fit(); }