File tree Expand file tree Collapse file tree 2 files changed +5
-10
lines changed Expand file tree Collapse file tree 2 files changed +5
-10
lines changed Original file line number Diff line number Diff line change @@ -626,8 +626,8 @@ where
626626 /// down no lower than the supplied limit while maintaining the internal rules
627627 /// and possibly leaving some space in accordance with the resize policy.
628628 ///
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.
631631 ///
632632 /// # Examples
633633 ///
@@ -642,14 +642,11 @@ where
642642 /// assert!(map.capacity() >= 10);
643643 /// map.shrink_to(0);
644644 /// assert!(map.capacity() >= 2);
645+ /// map.shrink_to(10);
646+ /// assert!(map.capacity() >= 2);
645647 /// ```
646648 #[ inline]
647649 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-
653650 let hash_builder = & self . hash_builder ;
654651 self . table
655652 . shrink_to ( min_capacity, |x| make_hash ( hash_builder, & x. 0 ) ) ;
Original file line number Diff line number Diff line change @@ -601,9 +601,7 @@ impl<T> RawTable<T> {
601601 } ;
602602
603603 // If we have more buckets than we need, shrink the table.
604- if min_buckets != self . buckets ( ) {
605- debug_assert ! ( min_buckets < self . buckets( ) ) ;
606-
604+ if min_buckets < self . buckets ( ) {
607605 // Fast path if the table is empty
608606 if self . items == 0 {
609607 * self = Self :: with_capacity ( min_size)
You can’t perform that action at this time.
0 commit comments