File tree 2 files changed +5
-10
lines changed
2 files changed +5
-10
lines changed Original file line number Diff line number Diff line change @@ -626,8 +626,8 @@ where
626
626
/// down no lower than the supplied limit while maintaining the internal rules
627
627
/// and possibly leaving some space in accordance with the resize policy.
628
628
///
629
- /// Panics if the current capacity is smaller than the supplied
630
- /// minimum capacity.
629
+ /// This function does nothing if the current capacity is smaller than the
630
+ /// supplied minimum capacity.
631
631
///
632
632
/// # Examples
633
633
///
@@ -642,14 +642,11 @@ where
642
642
/// assert!(map.capacity() >= 10);
643
643
/// map.shrink_to(0);
644
644
/// assert!(map.capacity() >= 2);
645
+ /// map.shrink_to(10);
646
+ /// assert!(map.capacity() >= 2);
645
647
/// ```
646
648
#[ inline]
647
649
pub fn shrink_to ( & mut self , min_capacity : usize ) {
648
- assert ! (
649
- self . capacity( ) >= min_capacity,
650
- "Tried to shrink to a larger capacity"
651
- ) ;
652
-
653
650
let hash_builder = & self . hash_builder ;
654
651
self . table
655
652
. shrink_to ( min_capacity, |x| make_hash ( hash_builder, & x. 0 ) ) ;
Original file line number Diff line number Diff line change @@ -599,9 +599,7 @@ impl<T> RawTable<T> {
599
599
} ;
600
600
601
601
// If we have more buckets than we need, shrink the table.
602
- if min_buckets != self . buckets ( ) {
603
- debug_assert ! ( min_buckets < self . buckets( ) ) ;
604
-
602
+ if min_buckets < self . buckets ( ) {
605
603
// Fast path if the table is empty
606
604
if self . items == 0 {
607
605
* self = Self :: with_capacity ( min_size)
You can’t perform that action at this time.
0 commit comments