@@ -24,7 +24,7 @@ use core::mem;
24
24
25
25
use crate :: collections:: TryReserveError ;
26
26
use crate :: collections:: TryReserveErrorKind ;
27
- use crate :: falloc:: { Allocator , Global } ;
27
+ use crate :: falloc:: { AllocResult , Allocator , ErrorHandling , Fatal , Global } ;
28
28
use crate :: raw_vec:: RawVec ;
29
29
use crate :: vec:: Vec ;
30
30
@@ -108,7 +108,7 @@ pub struct VecDeque<
108
108
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
109
109
impl < T : Clone , A > Clone for VecDeque < T , A >
110
110
where
111
- A : Allocator < Result < Self , TryReserveError > = Self > + Clone ,
111
+ A : Allocator < ErrorHandling = Fatal > + Clone ,
112
112
{
113
113
fn clone ( & self ) -> Self {
114
114
let mut deq = Self :: with_capacity_in ( self . len ( ) , self . allocator ( ) . clone ( ) ) ;
@@ -597,8 +597,8 @@ impl<T, A: Allocator> VecDeque<T, A> {
597
597
pub fn with_capacity_in (
598
598
capacity : usize ,
599
599
alloc : A ,
600
- ) -> A :: Result < VecDeque < T , A > , TryReserveError > {
601
- A :: map_result ( Self :: try_with_capacity_in ( capacity, alloc) )
600
+ ) -> AllocResult < A , VecDeque < T , A > , TryReserveError > {
601
+ A :: ErrorHandling :: map_result ( Self :: try_with_capacity_in ( capacity, alloc) )
602
602
}
603
603
604
604
/// Creates a `VecDeque` from a raw allocation, when the initialized
@@ -761,8 +761,8 @@ impl<T, A: Allocator> VecDeque<T, A> {
761
761
///
762
762
/// [`reserve`]: VecDeque::reserve
763
763
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
764
- pub fn reserve_exact ( & mut self , additional : usize ) -> A :: Result < ( ) , TryReserveError > {
765
- A :: map_result ( self . try_reserve_exact ( additional) )
764
+ pub fn reserve_exact ( & mut self , additional : usize ) -> AllocResult < A , ( ) , TryReserveError > {
765
+ A :: ErrorHandling :: map_result ( self . try_reserve_exact ( additional) )
766
766
}
767
767
768
768
/// Reserves capacity for at least `additional` more elements to be inserted in the given
@@ -782,8 +782,8 @@ impl<T, A: Allocator> VecDeque<T, A> {
782
782
/// assert!(buf.capacity() >= 11);
783
783
/// ```
784
784
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
785
- pub fn reserve ( & mut self , additional : usize ) -> A :: Result < ( ) , TryReserveError > {
786
- A :: map_result ( self . try_reserve ( additional) )
785
+ pub fn reserve ( & mut self , additional : usize ) -> AllocResult < A , ( ) , TryReserveError > {
786
+ A :: ErrorHandling :: map_result ( self . try_reserve ( additional) )
787
787
}
788
788
789
789
/// Tries to reserve the minimum capacity for at least `additional` more elements to
@@ -928,8 +928,8 @@ impl<T, A: Allocator> VecDeque<T, A> {
928
928
/// assert!(buf.capacity() >= 4);
929
929
/// ```
930
930
#[ stable( feature = "shrink_to" , since = "1.56.0" ) ]
931
- pub fn shrink_to ( & mut self , min_capacity : usize ) -> A :: Result < ( ) , TryReserveError > {
932
- A :: map_result ( ( || {
931
+ pub fn shrink_to ( & mut self , min_capacity : usize ) -> AllocResult < A , ( ) , TryReserveError > {
932
+ A :: ErrorHandling :: map_result ( ( || {
933
933
// Substitute for try block
934
934
let target_cap = min_capacity. max ( self . len ) ;
935
935
@@ -1625,8 +1625,8 @@ impl<T, A: Allocator> VecDeque<T, A> {
1625
1625
/// assert_eq!(d.front(), Some(&2));
1626
1626
/// ```
1627
1627
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1628
- pub fn push_front ( & mut self , value : T ) -> A :: Result < ( ) , TryReserveError > {
1629
- A :: map_result ( ( || {
1628
+ pub fn push_front ( & mut self , value : T ) -> AllocResult < A , ( ) , TryReserveError > {
1629
+ A :: ErrorHandling :: map_result ( ( || {
1630
1630
// Substitute for try block
1631
1631
if self . is_full ( ) {
1632
1632
self . grow ( ) ?;
@@ -1656,8 +1656,8 @@ impl<T, A: Allocator> VecDeque<T, A> {
1656
1656
/// assert_eq!(3, *buf.back().unwrap());
1657
1657
/// ```
1658
1658
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1659
- pub fn push_back ( & mut self , value : T ) -> A :: Result < ( ) , TryReserveError > {
1660
- A :: map_result ( ( || {
1659
+ pub fn push_back ( & mut self , value : T ) -> AllocResult < A , ( ) , TryReserveError > {
1660
+ A :: ErrorHandling :: map_result ( ( || {
1661
1661
// Substsitute for try block
1662
1662
if self . is_full ( ) {
1663
1663
self . grow ( ) ?;
@@ -1770,8 +1770,8 @@ impl<T, A: Allocator> VecDeque<T, A> {
1770
1770
/// assert_eq!(vec_deque, &['a', 'd', 'b', 'c']);
1771
1771
/// ```
1772
1772
#[ stable( feature = "deque_extras_15" , since = "1.5.0" ) ]
1773
- pub fn insert ( & mut self , index : usize , value : T ) -> A :: Result < ( ) , TryReserveError > {
1774
- A :: map_result ( ( || {
1773
+ pub fn insert ( & mut self , index : usize , value : T ) -> AllocResult < A , ( ) , TryReserveError > {
1774
+ A :: ErrorHandling :: map_result ( ( || {
1775
1775
// Substitute for try block
1776
1776
assert ! ( index <= self . len( ) , "index out of bounds" ) ;
1777
1777
if self . is_full ( ) {
@@ -1877,11 +1877,11 @@ impl<T, A: Allocator> VecDeque<T, A> {
1877
1877
#[ inline]
1878
1878
#[ must_use = "use `.truncate()` if you don't need the other half" ]
1879
1879
#[ stable( feature = "split_off" , since = "1.4.0" ) ]
1880
- pub fn split_off ( & mut self , at : usize ) -> A :: Result < Self , TryReserveError >
1880
+ pub fn split_off ( & mut self , at : usize ) -> AllocResult < A , Self , TryReserveError >
1881
1881
where
1882
1882
A : Clone ,
1883
1883
{
1884
- A :: map_result ( ( || {
1884
+ A :: ErrorHandling :: map_result ( ( || {
1885
1885
let len = self . len ;
1886
1886
assert ! ( at <= len, "`at` out of bounds" ) ;
1887
1887
0 commit comments