@@ -19,9 +19,10 @@ pub struct Drain<
19
19
' a ,
20
20
T : ' a ,
21
21
#[ unstable( feature = "allocator_api" , issue = "32838" ) ] A : Allocator = Global ,
22
- const COOP_PREFERRED : bool = { alloc:: SHORT_TERM_VEC_PREFERS_COOP }
23
- >
24
- where [ ( ) ; alloc:: co_alloc_metadata_num_slots_with_preference :: < A > ( COOP_PREFERRED ) ] : {
22
+ const COOP_PREFERRED : bool = { alloc:: SHORT_TERM_VEC_PREFERS_COOP } ,
23
+ > where
24
+ [ ( ) ; alloc:: co_alloc_metadata_num_slots_with_preference :: < A > ( COOP_PREFERRED ) ] : ,
25
+ {
25
26
// We can't just use a &mut VecDeque<T, A>, as that would make Drain invariant over T
26
27
// and we want it to be covariant instead
27
28
deque : NonNull < VecDeque < T , A , COOP_PREFERRED > > ,
@@ -37,7 +38,9 @@ where [(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRE
37
38
}
38
39
39
40
impl < ' a , T , A : Allocator , const COOP_PREFERRED : bool > Drain < ' a , T , A , COOP_PREFERRED >
40
- where [ ( ) ; alloc:: co_alloc_metadata_num_slots_with_preference :: < A > ( COOP_PREFERRED ) ] : {
41
+ where
42
+ [ ( ) ; alloc:: co_alloc_metadata_num_slots_with_preference :: < A > ( COOP_PREFERRED ) ] : ,
43
+ {
41
44
pub ( super ) unsafe fn new (
42
45
deque : & ' a mut VecDeque < T , A , COOP_PREFERRED > ,
43
46
drain_start : usize ,
@@ -91,8 +94,11 @@ where [(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRE
91
94
}
92
95
93
96
#[ stable( feature = "collection_debug" , since = "1.17.0" ) ]
94
- impl < T : fmt:: Debug , A : Allocator , const COOP_PREFERRED : bool > fmt:: Debug for Drain < ' _ , T , A , COOP_PREFERRED >
95
- where [ ( ) ; alloc:: co_alloc_metadata_num_slots_with_preference :: < A > ( COOP_PREFERRED ) ] : {
97
+ impl < T : fmt:: Debug , A : Allocator , const COOP_PREFERRED : bool > fmt:: Debug
98
+ for Drain < ' _ , T , A , COOP_PREFERRED >
99
+ where
100
+ [ ( ) ; alloc:: co_alloc_metadata_num_slots_with_preference :: < A > ( COOP_PREFERRED ) ] : ,
101
+ {
96
102
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
97
103
f. debug_tuple ( "Drain" )
98
104
. field ( & self . drain_len )
@@ -104,21 +110,37 @@ where [(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRE
104
110
}
105
111
106
112
#[ stable( feature = "drain" , since = "1.6.0" ) ]
107
- unsafe impl < T : Sync , A : Allocator + Sync , const COOP_PREFERRED : bool > Sync for Drain < ' _ , T , A , COOP_PREFERRED >
108
- where [ ( ) ; alloc:: co_alloc_metadata_num_slots_with_preference :: < A > ( COOP_PREFERRED ) ] : { }
113
+ unsafe impl < T : Sync , A : Allocator + Sync , const COOP_PREFERRED : bool > Sync
114
+ for Drain < ' _ , T , A , COOP_PREFERRED >
115
+ where
116
+ [ ( ) ; alloc:: co_alloc_metadata_num_slots_with_preference :: < A > ( COOP_PREFERRED ) ] : ,
117
+ {
118
+ }
109
119
#[ stable( feature = "drain" , since = "1.6.0" ) ]
110
- unsafe impl < T : Send , A : Allocator + Send , const COOP_PREFERRED : bool > Send for Drain < ' _ , T , A , COOP_PREFERRED >
111
- where [ ( ) ; alloc:: co_alloc_metadata_num_slots_with_preference :: < A > ( COOP_PREFERRED ) ] : { }
120
+ unsafe impl < T : Send , A : Allocator + Send , const COOP_PREFERRED : bool > Send
121
+ for Drain < ' _ , T , A , COOP_PREFERRED >
122
+ where
123
+ [ ( ) ; alloc:: co_alloc_metadata_num_slots_with_preference :: < A > ( COOP_PREFERRED ) ] : ,
124
+ {
125
+ }
112
126
113
127
#[ stable( feature = "drain" , since = "1.6.0" ) ]
114
128
impl < T , A : Allocator , const COOP_PREFERRED : bool > Drop for Drain < ' _ , T , A , COOP_PREFERRED >
115
- where [ ( ) ; alloc:: co_alloc_metadata_num_slots_with_preference :: < A > ( COOP_PREFERRED ) ] : {
129
+ where
130
+ [ ( ) ; alloc:: co_alloc_metadata_num_slots_with_preference :: < A > ( COOP_PREFERRED ) ] : ,
131
+ {
116
132
fn drop ( & mut self ) {
117
- struct DropGuard < ' r , ' a , T , A : Allocator , const COOP_PREFERRED : bool > ( & ' r mut Drain < ' a , T , A , COOP_PREFERRED > )
118
- where [ ( ) ; alloc:: co_alloc_metadata_num_slots_with_preference :: < A > ( COOP_PREFERRED ) ] : ;
133
+ struct DropGuard < ' r , ' a , T , A : Allocator , const COOP_PREFERRED : bool > (
134
+ & ' r mut Drain < ' a , T , A , COOP_PREFERRED > ,
135
+ )
136
+ where
137
+ [ ( ) ; alloc:: co_alloc_metadata_num_slots_with_preference :: < A > ( COOP_PREFERRED ) ] : ;
119
138
120
- impl < ' r , ' a , T , A : Allocator , const COOP_PREFERRED : bool > Drop for DropGuard < ' r , ' a , T , A , COOP_PREFERRED >
121
- where [ ( ) ; alloc:: co_alloc_metadata_num_slots_with_preference :: < A > ( COOP_PREFERRED ) ] : {
139
+ impl < ' r , ' a , T , A : Allocator , const COOP_PREFERRED : bool > Drop
140
+ for DropGuard < ' r , ' a , T , A , COOP_PREFERRED >
141
+ where
142
+ [ ( ) ; alloc:: co_alloc_metadata_num_slots_with_preference :: < A > ( COOP_PREFERRED ) ] : ,
143
+ {
122
144
fn drop ( & mut self ) {
123
145
if self . 0 . remaining != 0 {
124
146
unsafe {
@@ -200,7 +222,9 @@ where [(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRE
200
222
201
223
#[ stable( feature = "drain" , since = "1.6.0" ) ]
202
224
impl < T , A : Allocator , const COOP_PREFERRED : bool > Iterator for Drain < ' _ , T , A , COOP_PREFERRED >
203
- where [ ( ) ; alloc:: co_alloc_metadata_num_slots_with_preference :: < A > ( COOP_PREFERRED ) ] : {
225
+ where
226
+ [ ( ) ; alloc:: co_alloc_metadata_num_slots_with_preference :: < A > ( COOP_PREFERRED ) ] : ,
227
+ {
204
228
type Item = T ;
205
229
206
230
#[ inline]
@@ -222,8 +246,11 @@ where [(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRE
222
246
}
223
247
224
248
#[ stable( feature = "drain" , since = "1.6.0" ) ]
225
- impl < T , A : Allocator , const COOP_PREFERRED : bool > DoubleEndedIterator for Drain < ' _ , T , A , COOP_PREFERRED >
226
- where [ ( ) ; alloc:: co_alloc_metadata_num_slots_with_preference :: < A > ( COOP_PREFERRED ) ] : {
249
+ impl < T , A : Allocator , const COOP_PREFERRED : bool > DoubleEndedIterator
250
+ for Drain < ' _ , T , A , COOP_PREFERRED >
251
+ where
252
+ [ ( ) ; alloc:: co_alloc_metadata_num_slots_with_preference :: < A > ( COOP_PREFERRED ) ] : ,
253
+ {
227
254
#[ inline]
228
255
fn next_back ( & mut self ) -> Option < T > {
229
256
if self . remaining == 0 {
@@ -236,9 +263,15 @@ where [(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRE
236
263
}
237
264
238
265
#[ stable( feature = "drain" , since = "1.6.0" ) ]
239
- impl < T , A : Allocator , const COOP_PREFERRED : bool > ExactSizeIterator for Drain < ' _ , T , A , COOP_PREFERRED >
240
- where [ ( ) ; alloc:: co_alloc_metadata_num_slots_with_preference :: < A > ( COOP_PREFERRED ) ] : { }
266
+ impl < T , A : Allocator , const COOP_PREFERRED : bool > ExactSizeIterator
267
+ for Drain < ' _ , T , A , COOP_PREFERRED >
268
+ where
269
+ [ ( ) ; alloc:: co_alloc_metadata_num_slots_with_preference :: < A > ( COOP_PREFERRED ) ] : ,
270
+ {
271
+ }
241
272
242
273
#[ stable( feature = "fused" , since = "1.26.0" ) ]
243
- impl < T , A : Allocator , const COOP_PREFERRED : bool > FusedIterator for Drain < ' _ , T , A , COOP_PREFERRED >
244
- where [ ( ) ; alloc:: co_alloc_metadata_num_slots_with_preference :: < A > ( COOP_PREFERRED ) ] : { }
274
+ impl < T , A : Allocator , const COOP_PREFERRED : bool > FusedIterator for Drain < ' _ , T , A , COOP_PREFERRED > where
275
+ [ ( ) ; alloc:: co_alloc_metadata_num_slots_with_preference :: < A > ( COOP_PREFERRED ) ] :
276
+ {
277
+ }
0 commit comments