@@ -2,6 +2,8 @@ use core::iter::FusedIterator;
2
2
use core:: ptr:: { self , NonNull } ;
3
3
use core:: { fmt, mem} ;
4
4
5
+ use crate :: alloc:: { Allocator , Global } ;
6
+
5
7
use super :: { count, Iter , VecDeque } ;
6
8
7
9
/// A draining iterator over the elements of a `VecDeque`.
@@ -11,15 +13,19 @@ use super::{count, Iter, VecDeque};
11
13
///
12
14
/// [`drain`]: VecDeque::drain
13
15
#[ stable( feature = "drain" , since = "1.6.0" ) ]
14
- pub struct Drain < ' a , T : ' a > {
16
+ pub struct Drain <
17
+ ' a ,
18
+ T : ' a ,
19
+ #[ unstable( feature = "allocator_api" , issue = "32838" ) ] A : Allocator = Global ,
20
+ > {
15
21
pub ( crate ) after_tail : usize ,
16
22
pub ( crate ) after_head : usize ,
17
23
pub ( crate ) iter : Iter < ' a , T > ,
18
- pub ( crate ) deque : NonNull < VecDeque < T > > ,
24
+ pub ( crate ) deque : NonNull < VecDeque < T , A > > ,
19
25
}
20
26
21
27
#[ stable( feature = "collection_debug" , since = "1.17.0" ) ]
22
- impl < T : fmt:: Debug > fmt:: Debug for Drain < ' _ , T > {
28
+ impl < T : fmt:: Debug , A : Allocator > fmt:: Debug for Drain < ' _ , T , A > {
23
29
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
24
30
f. debug_tuple ( "Drain" )
25
31
. field ( & self . after_tail )
@@ -30,16 +36,16 @@ impl<T: fmt::Debug> fmt::Debug for Drain<'_, T> {
30
36
}
31
37
32
38
#[ stable( feature = "drain" , since = "1.6.0" ) ]
33
- unsafe impl < T : Sync > Sync for Drain < ' _ , T > { }
39
+ unsafe impl < T : Sync , A : Allocator + Sync > Sync for Drain < ' _ , T , A > { }
34
40
#[ stable( feature = "drain" , since = "1.6.0" ) ]
35
- unsafe impl < T : Send > Send for Drain < ' _ , T > { }
41
+ unsafe impl < T : Send , A : Allocator + Send > Send for Drain < ' _ , T , A > { }
36
42
37
43
#[ stable( feature = "drain" , since = "1.6.0" ) ]
38
- impl < T > Drop for Drain < ' _ , T > {
44
+ impl < T , A : Allocator > Drop for Drain < ' _ , T , A > {
39
45
fn drop ( & mut self ) {
40
- struct DropGuard < ' r , ' a , T > ( & ' r mut Drain < ' a , T > ) ;
46
+ struct DropGuard < ' r , ' a , T , A : Allocator > ( & ' r mut Drain < ' a , T , A > ) ;
41
47
42
- impl < ' r , ' a , T > Drop for DropGuard < ' r , ' a , T > {
48
+ impl < ' r , ' a , T , A : Allocator > Drop for DropGuard < ' r , ' a , T , A > {
43
49
fn drop ( & mut self ) {
44
50
self . 0 . for_each ( drop) ;
45
51
@@ -96,7 +102,7 @@ impl<T> Drop for Drain<'_, T> {
96
102
}
97
103
98
104
#[ stable( feature = "drain" , since = "1.6.0" ) ]
99
- impl < T > Iterator for Drain < ' _ , T > {
105
+ impl < T , A : Allocator > Iterator for Drain < ' _ , T , A > {
100
106
type Item = T ;
101
107
102
108
#[ inline]
@@ -111,15 +117,15 @@ impl<T> Iterator for Drain<'_, T> {
111
117
}
112
118
113
119
#[ stable( feature = "drain" , since = "1.6.0" ) ]
114
- impl < T > DoubleEndedIterator for Drain < ' _ , T > {
120
+ impl < T , A : Allocator > DoubleEndedIterator for Drain < ' _ , T , A > {
115
121
#[ inline]
116
122
fn next_back ( & mut self ) -> Option < T > {
117
123
self . iter . next_back ( ) . map ( |elt| unsafe { ptr:: read ( elt) } )
118
124
}
119
125
}
120
126
121
127
#[ stable( feature = "drain" , since = "1.6.0" ) ]
122
- impl < T > ExactSizeIterator for Drain < ' _ , T > { }
128
+ impl < T , A : Allocator > ExactSizeIterator for Drain < ' _ , T , A > { }
123
129
124
130
#[ stable( feature = "fused" , since = "1.26.0" ) ]
125
- impl < T > FusedIterator for Drain < ' _ , T > { }
131
+ impl < T , A : Allocator > FusedIterator for Drain < ' _ , T , A > { }
0 commit comments