@@ -43,7 +43,7 @@ use vint::VintArrayIterator;
43
43
// use self::Entry::*;
44
44
use self :: VacantEntryState :: * ;
45
45
use std:: cmp:: max;
46
- use std:: collections:: CollectionAllocErr ;
46
+ use std:: collections:: TryReserveError ;
47
47
use std:: fmt:: { self , Debug } ;
48
48
#[ allow( deprecated) ]
49
49
use std:: hash:: BuildHasher ;
@@ -74,7 +74,7 @@ impl DefaultResizePolicy {
74
74
/// provide that capacity, accounting for maximum loading. The raw capacity
75
75
/// is always zero or a power of two.
76
76
#[ inline]
77
- fn try_raw_capacity ( & self , len : usize ) -> Result < usize , CollectionAllocErr > {
77
+ fn try_raw_capacity ( & self , len : usize ) -> Result < usize , TryReserveError > {
78
78
if len == 0 {
79
79
Ok ( 0 )
80
80
} else {
@@ -85,7 +85,7 @@ impl DefaultResizePolicy {
85
85
. checked_mul ( 11 )
86
86
. map ( |l| l / 10 )
87
87
. and_then ( |l| l. checked_next_power_of_two ( ) )
88
- . ok_or ( CollectionAllocErr :: CapacityOverflow ) ?;
88
+ . ok_or ( TryReserveError :: CapacityOverflow ) ?;
89
89
90
90
raw_cap = max ( MIN_NONZERO_RAW_CAPACITY , raw_cap) ;
91
91
Ok ( raw_cap)
@@ -755,8 +755,8 @@ where
755
755
/// ```
756
756
pub fn reserve ( & mut self , additional : usize ) {
757
757
match self . reserve_internal ( additional, Infallible ) {
758
- Err ( CollectionAllocErr :: CapacityOverflow ) => panic ! ( "capacity overflow" ) ,
759
- Err ( CollectionAllocErr :: AllocErr ) => unreachable ! ( ) ,
758
+ Err ( TryReserveError :: CapacityOverflow ) => panic ! ( "capacity overflow" ) ,
759
+ Err ( TryReserveError :: AllocError { .. } ) => unreachable ! ( ) ,
760
760
Ok ( ( ) ) => { /* yay */ }
761
761
}
762
762
}
@@ -778,21 +778,21 @@ where
778
778
/// let mut map: HashMap<&str, isize> = HashMap::new();
779
779
/// map.try_reserve(10).expect("why is the test harness OOMing on 10 bytes?");
780
780
/// ```
781
- pub fn try_reserve ( & mut self , additional : usize ) -> Result < ( ) , CollectionAllocErr > {
781
+ pub fn try_reserve ( & mut self , additional : usize ) -> Result < ( ) , TryReserveError > {
782
782
self . reserve_internal ( additional, Fallible )
783
783
}
784
784
785
785
fn reserve_internal (
786
786
& mut self ,
787
787
additional : usize ,
788
788
fallibility : Fallibility ,
789
- ) -> Result < ( ) , CollectionAllocErr > {
789
+ ) -> Result < ( ) , TryReserveError > {
790
790
let remaining = self . capacity ( ) - self . len ( ) ; // this can't overflow
791
791
if remaining < additional {
792
792
let min_cap = self
793
793
. len ( )
794
794
. checked_add ( additional)
795
- . ok_or ( CollectionAllocErr :: CapacityOverflow ) ?;
795
+ . ok_or ( TryReserveError :: CapacityOverflow ) ?;
796
796
let raw_cap = self . resize_policy . try_raw_capacity ( min_cap) ?;
797
797
self . try_resize ( raw_cap, fallibility) ?;
798
798
} else if self . table . tag ( ) && remaining <= self . len ( ) {
@@ -815,7 +815,7 @@ where
815
815
& mut self ,
816
816
new_raw_cap : usize ,
817
817
fallibility : Fallibility ,
818
- ) -> Result < ( ) , CollectionAllocErr > {
818
+ ) -> Result < ( ) , TryReserveError > {
819
819
assert ! ( self . table. size( ) <= new_raw_cap) ;
820
820
assert ! ( new_raw_cap. is_power_of_two( ) || new_raw_cap == 0 ) ;
821
821
@@ -1505,7 +1505,7 @@ where
1505
1505
if disp >= DISPLACEMENT_THRESHOLD {
1506
1506
bucket. table_mut ( ) . set_tag ( true ) ;
1507
1507
}
1508
- let mut text_position =
1508
+ let text_position =
1509
1509
add_and_get_text_position ( key, & mut bucket. table_mut ( ) . raw_text_data ) ;
1510
1510
bucket. put ( hash, text_position, value)
1511
1511
}
@@ -2379,7 +2379,7 @@ mod test_map {
2379
2379
// if let Err(CapacityOverflow) = empty_bytes.try_reserve(max_no_ovf) {
2380
2380
// } else { panic!("isize::MAX + 1 should trigger a CapacityOverflow!") }
2381
2381
// } else {
2382
- // if let Err(AllocErr ) = empty_bytes.try_reserve(max_no_ovf) {
2382
+ // if let Err(AllocError ) = empty_bytes.try_reserve(max_no_ovf) {
2383
2383
// } else { panic!("isize::MAX + 1 should trigger an OOM!") }
2384
2384
// }
2385
2385
// }
0 commit comments