Skip to content

Commit d5c8be6

Browse files
committed
add shrink_to_fit test
1 parent 488dbfa commit d5c8be6

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/lib.rs

+13
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,19 @@ impl<'a, K: 'a + Eq + Hash, V: 'a, S: BuildHasher + Clone> DashMap<K, V, S> {
667667
/// Remove excess capacity to reduce memory usage.
668668
///
669669
/// **Locking behaviour:** May deadlock if called when holding any sort of reference into the map.
670+
/// # Examples
671+
///
672+
/// ```
673+
/// use dashmap::DashMap;
674+
/// use dashmap::try_result::TryResult;
675+
///
676+
/// let map = DashMap::new();
677+
/// map.insert("Johnny", 21);
678+
/// assert!(map.capacity() > 0);
679+
/// map.remove("Johnny");
680+
/// map.shrink_to_fit();
681+
/// assert_eq!(map.capacity(), 0);
682+
/// ```
670683
pub fn shrink_to_fit(&self) {
671684
self._shrink_to_fit();
672685
}

0 commit comments

Comments
 (0)