@@ -19,9 +19,10 @@ pub struct Drain<
1919 ' a ,
2020 T : ' a ,
2121 #[ 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+ {
2526 // We can't just use a &mut VecDeque<T, A>, as that would make Drain invariant over T
2627 // and we want it to be covariant instead
2728 deque : NonNull < VecDeque < T , A , COOP_PREFERRED > > ,
@@ -37,7 +38,9 @@ where [(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRE
3738}
3839
3940impl < ' 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+ {
4144 pub ( super ) unsafe fn new (
4245 deque : & ' a mut VecDeque < T , A , COOP_PREFERRED > ,
4346 drain_start : usize ,
@@ -91,8 +94,11 @@ where [(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRE
9194}
9295
9396#[ 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+ {
96102 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
97103 f. debug_tuple ( "Drain" )
98104 . field ( & self . drain_len )
@@ -104,21 +110,37 @@ where [(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRE
104110}
105111
106112#[ 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+ }
109119#[ 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+ }
112126
113127#[ stable( feature = "drain" , since = "1.6.0" ) ]
114128impl < 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+ {
116132 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 ) ] : ;
119138
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+ {
122144 fn drop ( & mut self ) {
123145 if self . 0 . remaining != 0 {
124146 unsafe {
@@ -200,7 +222,9 @@ where [(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRE
200222
201223#[ stable( feature = "drain" , since = "1.6.0" ) ]
202224impl < 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+ {
204228 type Item = T ;
205229
206230 #[ inline]
@@ -222,8 +246,11 @@ where [(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRE
222246}
223247
224248#[ 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+ {
227254 #[ inline]
228255 fn next_back ( & mut self ) -> Option < T > {
229256 if self . remaining == 0 {
@@ -236,9 +263,15 @@ where [(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRE
236263}
237264
238265#[ 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+ }
241272
242273#[ 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