@@ -673,7 +673,7 @@ impl<T, A: Allocator> Vec<T, A> {
673
673
/// ```
674
674
#[ inline]
675
675
#[ unstable( feature = "allocator_api" , issue = "32838" ) ]
676
- pub fn with_capacity_in ( capacity : usize , alloc : A ) -> A :: Result < Self > {
676
+ pub fn with_capacity_in ( capacity : usize , alloc : A ) -> A :: Result < Self , TryReserveError > {
677
677
A :: map_result ( Self :: try_with_capacity_in ( capacity, alloc) )
678
678
}
679
679
@@ -908,7 +908,7 @@ impl<T, A: Allocator> Vec<T, A> {
908
908
/// assert!(vec.capacity() >= 11);
909
909
/// ```
910
910
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
911
- pub fn reserve ( & mut self , additional : usize ) -> A :: Result < ( ) > {
911
+ pub fn reserve ( & mut self , additional : usize ) -> A :: Result < ( ) , TryReserveError > {
912
912
A :: map_result ( self . try_reserve ( additional) )
913
913
}
914
914
@@ -937,7 +937,7 @@ impl<T, A: Allocator> Vec<T, A> {
937
937
/// assert!(vec.capacity() >= 11);
938
938
/// ```
939
939
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
940
- pub fn reserve_exact ( & mut self , additional : usize ) -> A :: Result < ( ) > {
940
+ pub fn reserve_exact ( & mut self , additional : usize ) -> A :: Result < ( ) , TryReserveError > {
941
941
A :: map_result ( self . try_reserve_exact ( additional) )
942
942
}
943
943
@@ -1047,7 +1047,7 @@ impl<T, A: Allocator> Vec<T, A> {
1047
1047
/// assert!(vec.capacity() >= 3);
1048
1048
/// ```
1049
1049
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1050
- pub fn shrink_to_fit ( & mut self ) -> A :: Result < ( ) > {
1050
+ pub fn shrink_to_fit ( & mut self ) -> A :: Result < ( ) , TryReserveError > {
1051
1051
A :: map_result ( self . try_shrink_to_fit ( ) )
1052
1052
}
1053
1053
@@ -1070,7 +1070,7 @@ impl<T, A: Allocator> Vec<T, A> {
1070
1070
/// assert!(vec.capacity() >= 3);
1071
1071
/// ```
1072
1072
#[ stable( feature = "shrink_to" , since = "1.56.0" ) ]
1073
- pub fn shrink_to ( & mut self , min_capacity : usize ) -> A :: Result < ( ) > {
1073
+ pub fn shrink_to ( & mut self , min_capacity : usize ) -> A :: Result < ( ) , TryReserveError > {
1074
1074
A :: map_result ( if self . capacity ( ) > min_capacity {
1075
1075
self . buf . shrink_to ( cmp:: max ( self . len , min_capacity) )
1076
1076
} else {
@@ -1104,7 +1104,7 @@ impl<T, A: Allocator> Vec<T, A> {
1104
1104
/// assert_eq!(slice.into_vec().capacity(), 3);
1105
1105
/// ```
1106
1106
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1107
- pub fn into_boxed_slice ( mut self ) -> A :: Result < Box < [ T ] , A > > {
1107
+ pub fn into_boxed_slice ( mut self ) -> A :: Result < Box < [ T ] , A > , TryReserveError > {
1108
1108
A :: map_result ( ( || {
1109
1109
// Substitute for try block
1110
1110
self . try_shrink_to_fit ( ) ?;
@@ -1442,7 +1442,7 @@ impl<T, A: Allocator> Vec<T, A> {
1442
1442
/// assert_eq!(vec, [1, 4, 2, 3, 5]);
1443
1443
/// ```
1444
1444
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1445
- pub fn insert ( & mut self , index : usize , element : T ) -> A :: Result < ( ) > {
1445
+ pub fn insert ( & mut self , index : usize , element : T ) -> A :: Result < ( ) , TryReserveError > {
1446
1446
A :: map_result ( ( || {
1447
1447
// Substitute for try block
1448
1448
#[ cold]
@@ -1835,7 +1835,7 @@ impl<T, A: Allocator> Vec<T, A> {
1835
1835
/// ```
1836
1836
#[ inline]
1837
1837
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1838
- pub fn push ( & mut self , value : T ) -> A :: Result < ( ) > {
1838
+ pub fn push ( & mut self , value : T ) -> A :: Result < ( ) , TryReserveError > {
1839
1839
A :: map_result ( ( || {
1840
1840
// Substitute for try block
1841
1841
// This will panic or abort if we would allocate > isize::MAX bytes
@@ -1943,7 +1943,7 @@ impl<T, A: Allocator> Vec<T, A> {
1943
1943
/// ```
1944
1944
#[ inline]
1945
1945
#[ stable( feature = "append" , since = "1.4.0" ) ]
1946
- pub fn append ( & mut self , other : & mut Self ) -> A :: Result < ( ) > {
1946
+ pub fn append ( & mut self , other : & mut Self ) -> A :: Result < ( ) , TryReserveError > {
1947
1947
A :: map_result ( ( || {
1948
1948
// Substitute for try block
1949
1949
unsafe {
@@ -2111,7 +2111,7 @@ impl<T, A: Allocator> Vec<T, A> {
2111
2111
#[ inline]
2112
2112
#[ must_use = "use `.truncate()` if you don't need the other half" ]
2113
2113
#[ stable( feature = "split_off" , since = "1.4.0" ) ]
2114
- pub fn split_off ( & mut self , at : usize ) -> A :: Result < Self >
2114
+ pub fn split_off ( & mut self , at : usize ) -> A :: Result < Self , TryReserveError >
2115
2115
where
2116
2116
A : Clone ,
2117
2117
{
@@ -2176,7 +2176,7 @@ impl<T, A: Allocator> Vec<T, A> {
2176
2176
/// assert_eq!(vec, [2, 4, 8, 16]);
2177
2177
/// ```
2178
2178
#[ stable( feature = "vec_resize_with" , since = "1.33.0" ) ]
2179
- pub fn resize_with < F > ( & mut self , new_len : usize , f : F ) -> A :: Result < ( ) >
2179
+ pub fn resize_with < F > ( & mut self , new_len : usize , f : F ) -> A :: Result < ( ) , TryReserveError >
2180
2180
where
2181
2181
F : FnMut ( ) -> T ,
2182
2182
{
@@ -2380,7 +2380,7 @@ impl<T: Clone, A: Allocator> Vec<T, A> {
2380
2380
/// assert_eq!(vec, [1, 2]);
2381
2381
/// ```
2382
2382
#[ stable( feature = "vec_resize" , since = "1.5.0" ) ]
2383
- pub fn resize ( & mut self , new_len : usize , value : T ) -> A :: Result < ( ) > {
2383
+ pub fn resize ( & mut self , new_len : usize , value : T ) -> A :: Result < ( ) , TryReserveError > {
2384
2384
A :: map_result ( ( || {
2385
2385
// Substitute for try block
2386
2386
let len = self . len ( ) ;
@@ -2416,7 +2416,7 @@ impl<T: Clone, A: Allocator> Vec<T, A> {
2416
2416
/// [`extend`]: Vec::extend
2417
2417
#[ cfg( not( no_global_oom_handling) ) ]
2418
2418
#[ stable( feature = "vec_extend_from_slice" , since = "1.6.0" ) ]
2419
- pub fn extend_from_slice ( & mut self , other : & [ T ] ) -> A :: Result < ( ) > {
2419
+ pub fn extend_from_slice ( & mut self , other : & [ T ] ) -> A :: Result < ( ) , TryReserveError > {
2420
2420
A :: map_result ( self . spec_extend ( other. iter ( ) ) )
2421
2421
}
2422
2422
@@ -2443,7 +2443,7 @@ impl<T: Clone, A: Allocator> Vec<T, A> {
2443
2443
/// ```
2444
2444
#[ cfg( not( no_global_oom_handling) ) ]
2445
2445
#[ stable( feature = "vec_extend_from_within" , since = "1.53.0" ) ]
2446
- pub fn extend_from_within < R > ( & mut self , src : R ) -> A :: Result < ( ) >
2446
+ pub fn extend_from_within < R > ( & mut self , src : R ) -> A :: Result < ( ) , TryReserveError >
2447
2447
where
2448
2448
R : RangeBounds < usize > ,
2449
2449
{
@@ -2570,13 +2570,20 @@ impl<T: PartialEq, A: Allocator> Vec<T, A> {
2570
2570
2571
2571
#[ doc( hidden) ]
2572
2572
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2573
- pub fn from_elem < T : Clone > ( elem : T , n : usize ) -> <Global as Allocator >:: Result < Vec < T > > {
2573
+ pub fn from_elem < T : Clone > (
2574
+ elem : T ,
2575
+ n : usize ,
2576
+ ) -> <Global as Allocator >:: Result < Vec < T > , TryReserveError > {
2574
2577
<Global as Allocator >:: map_result ( <T as SpecFromElem >:: from_elem ( elem, n, Global ) )
2575
2578
}
2576
2579
2577
2580
#[ doc( hidden) ]
2578
2581
#[ unstable( feature = "allocator_api" , issue = "32838" ) ]
2579
- pub fn from_elem_in < T : Clone , A : Allocator > ( elem : T , n : usize , alloc : A ) -> A :: Result < Vec < T , A > > {
2582
+ pub fn from_elem_in < T : Clone , A : Allocator > (
2583
+ elem : T ,
2584
+ n : usize ,
2585
+ alloc : A ,
2586
+ ) -> A :: Result < Vec < T , A > , TryReserveError > {
2580
2587
A :: map_result ( <T as SpecFromElem >:: from_elem ( elem, n, alloc) )
2581
2588
}
2582
2589
@@ -2801,7 +2808,7 @@ impl<'a, T, A: Allocator> IntoIterator for &'a mut Vec<T, A> {
2801
2808
}
2802
2809
2803
2810
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2804
- impl < T , A : Allocator < Result < ( ) > = ( ) > > Extend < T > for Vec < T , A > {
2811
+ impl < T , A : Allocator < Result < ( ) , TryReserveError > = ( ) > > Extend < T > for Vec < T , A > {
2805
2812
#[ inline]
2806
2813
fn extend < I : IntoIterator < Item = T > > ( & mut self , iter : I ) {
2807
2814
A :: map_result ( <Self as SpecExtend < T , I :: IntoIter > >:: spec_extend ( self , iter. into_iter ( ) ) )
@@ -2928,7 +2935,7 @@ impl<T, A: Allocator> Vec<T, A> {
2928
2935
where
2929
2936
R : RangeBounds < usize > ,
2930
2937
I : IntoIterator < Item = T > ,
2931
- A : Allocator < Result < ( ) > = ( ) > ,
2938
+ A : Allocator < Result < ( ) , TryReserveError > = ( ) > ,
2932
2939
{
2933
2940
Splice { drain : self . drain ( range) , replace_with : replace_with. into_iter ( ) }
2934
2941
}
@@ -3000,7 +3007,9 @@ impl<T, A: Allocator> Vec<T, A> {
3000
3007
///
3001
3008
/// [`copy_from_slice`]: slice::copy_from_slice
3002
3009
#[ stable( feature = "extend_ref" , since = "1.2.0" ) ]
3003
- impl < ' a , T : Copy + ' a , A : Allocator < Result < ( ) > = ( ) > + ' a > Extend < & ' a T > for Vec < T , A > {
3010
+ impl < ' a , T : Copy + ' a , A : Allocator < Result < ( ) , TryReserveError > = ( ) > + ' a > Extend < & ' a T >
3011
+ for Vec < T , A >
3012
+ {
3004
3013
fn extend < I : IntoIterator < Item = & ' a T > > ( & mut self , iter : I ) {
3005
3014
A :: map_result ( self . spec_extend ( iter. into_iter ( ) ) )
3006
3015
}
@@ -3203,7 +3212,7 @@ impl<T, A: Allocator> From<Box<[T], A>> for Vec<T, A> {
3203
3212
#[ stable( feature = "box_from_vec" , since = "1.20.0" ) ]
3204
3213
impl < T , A > From < Vec < T , A > > for Box < [ T ] , A >
3205
3214
where
3206
- A : Allocator < Result < Self > = Self > ,
3215
+ A : Allocator < Result < Self , TryReserveError > = Self > ,
3207
3216
{
3208
3217
/// Convert a vector into a boxed slice.
3209
3218
///
0 commit comments