Skip to content

Commit

Permalink
add shrink_to_fit test
Browse files Browse the repository at this point in the history
  • Loading branch information
xacrimon committed Jun 24, 2024
1 parent 488dbfa commit d5c8be6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,19 @@ impl<'a, K: 'a + Eq + Hash, V: 'a, S: BuildHasher + Clone> DashMap<K, V, S> {
/// 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();
}
Expand Down

0 comments on commit d5c8be6

Please sign in to comment.