1- use core:: iter:: FusedIterator ;
21use crate :: co_alloc:: CoAllocPref ;
2+ use core:: iter:: FusedIterator ;
33use core:: marker:: PhantomData ;
44use core:: mem:: { self , SizedTypeProperties } ;
55use core:: ptr:: NonNull ;
@@ -23,10 +23,8 @@ pub struct Drain<
2323 #[ unstable( feature = "allocator_api" , issue = "32838" ) ] A : Allocator = Global ,
2424 const CO_ALLOC_PREF : CoAllocPref = { SHORT_TERM_VEC_CO_ALLOC_PREF ! ( ) } ,
2525> where
26- [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] : ,
26+ [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] : ,
2727{
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
3028 deque : NonNull < VecDeque < T , A , CO_ALLOC_PREF > > ,
3129 // drain_start is stored in deque.len
3230 drain_len : usize ,
@@ -42,7 +40,7 @@ pub struct Drain<
4240#[ allow( unused_braces) ]
4341impl < ' a , T , A : Allocator , const CO_ALLOC_PREF : CoAllocPref > Drain < ' a , T , A , CO_ALLOC_PREF >
4442where
45- [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] : ,
43+ [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] : ,
4644{
4745 pub ( super ) unsafe fn new (
4846 deque : & ' a mut VecDeque < T , A , CO_ALLOC_PREF > ,
9896
9997#[ stable( feature = "collection_debug" , since = "1.17.0" ) ]
10098#[ 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 >
102101where
103- [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] : ,
102+ [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] : ,
104103{
105104 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
106105 f. debug_tuple ( "Drain" )
@@ -114,33 +113,38 @@ where
114113
115114#[ stable( feature = "drain" , since = "1.6.0" ) ]
116115#[ 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 ) } ] : ,
119120{
120121}
121122#[ stable( feature = "drain" , since = "1.6.0" ) ]
122123#[ 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 ) } ] : ,
125128{
126129}
127130
128131#[ stable( feature = "drain" , since = "1.6.0" ) ]
129132#[ allow( unused_braces) ]
130133impl < T , A : Allocator , const CO_ALLOC_PREF : CoAllocPref > Drop for Drain < ' _ , T , A , CO_ALLOC_PREF >
131134where
132- [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] : ,
135+ [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] : ,
133136{
134137 fn drop ( & mut self ) {
135138 struct DropGuard < ' r , ' a , T , A : Allocator , const CO_ALLOC_PREF : CoAllocPref > (
136139 & ' r mut Drain < ' a , T , A , CO_ALLOC_PREF > ,
137140 )
138141 where
139- [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] : ;
142+ [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] : ;
140143
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 >
142146 where
143- [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] : ,
147+ [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] : ,
144148 {
145149 fn drop ( & mut self ) {
146150 if self . 0 . remaining != 0 {
@@ -225,7 +229,7 @@ where
225229#[ allow( unused_braces) ]
226230impl < T , A : Allocator , const CO_ALLOC_PREF : CoAllocPref > Iterator for Drain < ' _ , T , A , CO_ALLOC_PREF >
227231where
228- [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] : ,
232+ [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] : ,
229233{
230234 type Item = T ;
231235
@@ -249,9 +253,10 @@ where
249253
250254#[ stable( feature = "drain" , since = "1.6.0" ) ]
251255#[ 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 >
253258where
254- [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] : ,
259+ [ ( ) ; { crate :: meta_num_slots!( A , CO_ALLOC_PREF ) } ] : ,
255260{
256261 #[ inline]
257262 fn next_back ( & mut self ) -> Option < T > {
@@ -266,14 +271,18 @@ where
266271
267272#[ stable( feature = "drain" , since = "1.6.0" ) ]
268273#[ 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 ) } ] : ,
271278{
272279}
273280
274281#[ stable( feature = "fused" , since = "1.26.0" ) ]
275282#[ 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 ) } ] : ,
278287{
279288}
0 commit comments