1
- use core:: iter:: FusedIterator ;
2
1
use crate :: co_alloc:: CoAllocPref ;
2
+ use core:: iter:: FusedIterator ;
3
3
use core:: marker:: PhantomData ;
4
4
use core:: mem:: { self , SizedTypeProperties } ;
5
5
use core:: ptr:: NonNull ;
@@ -23,10 +23,8 @@ pub struct Drain<
23
23
#[ unstable( feature = "allocator_api" , issue = "32838" ) ] A : Allocator = Global ,
24
24
const CO_ALLOC_PREF : CoAllocPref = { SHORT_TERM_VEC_CO_ALLOC_PREF ! ( ) } ,
25
25
> where
26
- [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] : ,
26
+ [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] : ,
27
27
{
28
- // We can't just use a &mut VecDeque<T, A>, as that would make Drain invariant over T
29
- // and we want it to be covariant instead
30
28
deque : NonNull < VecDeque < T , A , CO_ALLOC_PREF > > ,
31
29
// drain_start is stored in deque.len
32
30
drain_len : usize ,
@@ -42,7 +40,7 @@ pub struct Drain<
42
40
#[ allow( unused_braces) ]
43
41
impl < ' a , T , A : Allocator , const CO_ALLOC_PREF : CoAllocPref > Drain < ' a , T , A , CO_ALLOC_PREF >
44
42
where
45
- [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] : ,
43
+ [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] : ,
46
44
{
47
45
pub ( super ) unsafe fn new (
48
46
deque : & ' a mut VecDeque < T , A , CO_ALLOC_PREF > ,
98
96
99
97
#[ stable( feature = "collection_debug" , since = "1.17.0" ) ]
100
98
#[ allow( unused_braces) ]
101
- impl < T : fmt:: Debug , A : Allocator , const CO_ALLOC_PREF : CoAllocPref > fmt:: Debug for Drain < ' _ , T , A , CO_ALLOC_PREF >
99
+ impl < T : fmt:: Debug , A : Allocator , const CO_ALLOC_PREF : CoAllocPref > fmt:: Debug
100
+ for Drain < ' _ , T , A , CO_ALLOC_PREF >
102
101
where
103
- [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] : ,
102
+ [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] : ,
104
103
{
105
104
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
106
105
f. debug_tuple ( "Drain" )
@@ -114,33 +113,38 @@ where
114
113
115
114
#[ stable( feature = "drain" , since = "1.6.0" ) ]
116
115
#[ allow( unused_braces) ]
117
- unsafe impl < T : Sync , A : Allocator + Sync , const CO_ALLOC_PREF : CoAllocPref > Sync for Drain < ' _ , T , A , CO_ALLOC_PREF > where
118
- [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] :
116
+ unsafe impl < T : Sync , A : Allocator + Sync , const CO_ALLOC_PREF : CoAllocPref > Sync
117
+ for Drain < ' _ , T , A , CO_ALLOC_PREF >
118
+ where
119
+ [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] : ,
119
120
{
120
121
}
121
122
#[ stable( feature = "drain" , since = "1.6.0" ) ]
122
123
#[ allow( unused_braces) ]
123
- unsafe impl < T : Send , A : Allocator + Send , const CO_ALLOC_PREF : CoAllocPref > Send for Drain < ' _ , T , A , CO_ALLOC_PREF > where
124
- [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] :
124
+ unsafe impl < T : Send , A : Allocator + Send , const CO_ALLOC_PREF : CoAllocPref > Send
125
+ for Drain < ' _ , T , A , CO_ALLOC_PREF >
126
+ where
127
+ [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] : ,
125
128
{
126
129
}
127
130
128
131
#[ stable( feature = "drain" , since = "1.6.0" ) ]
129
132
#[ allow( unused_braces) ]
130
133
impl < T , A : Allocator , const CO_ALLOC_PREF : CoAllocPref > Drop for Drain < ' _ , T , A , CO_ALLOC_PREF >
131
134
where
132
- [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] : ,
135
+ [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] : ,
133
136
{
134
137
fn drop ( & mut self ) {
135
138
struct DropGuard < ' r , ' a , T , A : Allocator , const CO_ALLOC_PREF : CoAllocPref > (
136
139
& ' r mut Drain < ' a , T , A , CO_ALLOC_PREF > ,
137
140
)
138
141
where
139
- [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] : ;
142
+ [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] : ;
140
143
141
- impl < ' r , ' a , T , A : Allocator , const CO_ALLOC_PREF : CoAllocPref > Drop for DropGuard < ' r , ' a , T , A , CO_ALLOC_PREF >
144
+ impl < ' r , ' a , T , A : Allocator , const CO_ALLOC_PREF : CoAllocPref > Drop
145
+ for DropGuard < ' r , ' a , T , A , CO_ALLOC_PREF >
142
146
where
143
- [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] : ,
147
+ [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] : ,
144
148
{
145
149
fn drop ( & mut self ) {
146
150
if self . 0 . remaining != 0 {
@@ -225,7 +229,7 @@ where
225
229
#[ allow( unused_braces) ]
226
230
impl < T , A : Allocator , const CO_ALLOC_PREF : CoAllocPref > Iterator for Drain < ' _ , T , A , CO_ALLOC_PREF >
227
231
where
228
- [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] : ,
232
+ [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] : ,
229
233
{
230
234
type Item = T ;
231
235
@@ -249,9 +253,10 @@ where
249
253
250
254
#[ stable( feature = "drain" , since = "1.6.0" ) ]
251
255
#[ allow( unused_braces) ]
252
- impl < T , A : Allocator , const CO_ALLOC_PREF : CoAllocPref > DoubleEndedIterator for Drain < ' _ , T , A , CO_ALLOC_PREF >
256
+ impl < T , A : Allocator , const CO_ALLOC_PREF : CoAllocPref > DoubleEndedIterator
257
+ for Drain < ' _ , T , A , CO_ALLOC_PREF >
253
258
where
254
- [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] : ,
259
+ [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] : ,
255
260
{
256
261
#[ inline]
257
262
fn next_back ( & mut self ) -> Option < T > {
@@ -266,14 +271,18 @@ where
266
271
267
272
#[ stable( feature = "drain" , since = "1.6.0" ) ]
268
273
#[ allow( unused_braces) ]
269
- impl < T , A : Allocator , const CO_ALLOC_PREF : CoAllocPref > ExactSizeIterator for Drain < ' _ , T , A , CO_ALLOC_PREF > where
270
- [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] :
274
+ impl < T , A : Allocator , const CO_ALLOC_PREF : CoAllocPref > ExactSizeIterator
275
+ for Drain < ' _ , T , A , CO_ALLOC_PREF >
276
+ where
277
+ [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] : ,
271
278
{
272
279
}
273
280
274
281
#[ stable( feature = "fused" , since = "1.26.0" ) ]
275
282
#[ allow( unused_braces) ]
276
- impl < T , A : Allocator , const CO_ALLOC_PREF : CoAllocPref > FusedIterator for Drain < ' _ , T , A , CO_ALLOC_PREF > where
277
- [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] :
283
+ impl < T , A : Allocator , const CO_ALLOC_PREF : CoAllocPref > FusedIterator
284
+ for Drain < ' _ , T , A , CO_ALLOC_PREF >
285
+ where
286
+ [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] : ,
278
287
{
279
288
}
0 commit comments