@@ -417,7 +417,7 @@ impl<T> RawTable<T> {
417
417
418
418
/// Attempts to allocate a new hash table with at least enough capacity
419
419
/// for inserting the given number of elements without reallocating.
420
- fn try_with_capacity (
420
+ fn fallible_with_capacity (
421
421
capacity : usize ,
422
422
fallability : Fallibility ,
423
423
) -> Result < Self , TryReserveError > {
@@ -435,10 +435,17 @@ impl<T> RawTable<T> {
435
435
}
436
436
}
437
437
438
+ /// Attempts to allocate a new hash table with at least enough capacity
439
+ /// for inserting the given number of elements without reallocating.
440
+ #[ cfg( feature = "raw" ) ]
441
+ pub fn try_with_capacity ( capacity : usize ) -> Result < Self , TryReserveError > {
442
+ Self :: fallible_with_capacity ( capacity, Fallibility :: Fallible )
443
+ }
444
+
438
445
/// Allocates a new hash table with at least enough capacity for inserting
439
446
/// the given number of elements without reallocating.
440
447
pub fn with_capacity ( capacity : usize ) -> Self {
441
- Self :: try_with_capacity ( capacity, Fallibility :: Infallible )
448
+ Self :: fallible_with_capacity ( capacity, Fallibility :: Infallible )
442
449
. unwrap_or_else ( |_| unsafe { hint:: unreachable_unchecked ( ) } )
443
450
}
444
451
@@ -834,7 +841,7 @@ impl<T> RawTable<T> {
834
841
debug_assert ! ( self . items <= capacity) ;
835
842
836
843
// Allocate and initialize the new table.
837
- let mut new_table = Self :: try_with_capacity ( capacity, fallability) ?;
844
+ let mut new_table = Self :: fallible_with_capacity ( capacity, fallability) ?;
838
845
new_table. growth_left -= self . items ;
839
846
new_table. items = self . items ;
840
847
0 commit comments