@@ -3,7 +3,7 @@ use core::fmt;
33use core:: iter:: { FusedIterator , TrustedLen } ;
44use core:: mem:: { self , ManuallyDrop , SizedTypeProperties } ;
55use core:: ptr:: { self , NonNull } ;
6- use core:: slice :: { self } ;
6+ use core:: { alloc , slice } ;
77
88use super :: Vec ;
99
@@ -23,7 +23,8 @@ pub struct Drain<
2323 ' a ,
2424 T : ' a ,
2525 #[ unstable( feature = "allocator_api" , issue = "32838" ) ] A : Allocator + ' a = Global ,
26- > {
26+ >
27+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
2728 /// Index of tail to preserve
2829 pub ( super ) tail_start : usize ,
2930 /// Length of tail
@@ -34,13 +35,15 @@ pub struct Drain<
3435}
3536
3637#[ stable( feature = "collection_debug" , since = "1.17.0" ) ]
37- impl < T : fmt:: Debug , A : Allocator > fmt:: Debug for Drain < ' _ , T , A > {
38+ impl < T : fmt:: Debug , A : Allocator > fmt:: Debug for Drain < ' _ , T , A >
39+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
3840 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
3941 f. debug_tuple ( "Drain" ) . field ( & self . iter . as_slice ( ) ) . finish ( )
4042 }
4143}
4244
43- impl < ' a , T , A : Allocator > Drain < ' a , T , A > {
45+ impl < ' a , T , A : Allocator > Drain < ' a , T , A >
46+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
4447 /// Returns the remaining items of this iterator as a slice.
4548 ///
4649 /// # Examples
@@ -139,19 +142,23 @@ impl<'a, T, A: Allocator> Drain<'a, T, A> {
139142}
140143
141144#[ stable( feature = "vec_drain_as_slice" , since = "1.46.0" ) ]
142- impl < ' a , T , A : Allocator > AsRef < [ T ] > for Drain < ' a , T , A > {
145+ impl < ' a , T , A : Allocator > AsRef < [ T ] > for Drain < ' a , T , A >
146+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
143147 fn as_ref ( & self ) -> & [ T ] {
144148 self . as_slice ( )
145149 }
146150}
147151
148152#[ stable( feature = "drain" , since = "1.6.0" ) ]
149- unsafe impl < T : Sync , A : Sync + Allocator > Sync for Drain < ' _ , T , A > { }
153+ unsafe impl < T : Sync , A : Sync + Allocator > Sync for Drain < ' _ , T , A >
154+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : { }
150155#[ stable( feature = "drain" , since = "1.6.0" ) ]
151- unsafe impl < T : Send , A : Send + Allocator > Send for Drain < ' _ , T , A > { }
156+ unsafe impl < T : Send , A : Send + Allocator > Send for Drain < ' _ , T , A >
157+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : { }
152158
153159#[ stable( feature = "drain" , since = "1.6.0" ) ]
154- impl < T , A : Allocator > Iterator for Drain < ' _ , T , A > {
160+ impl < T , A : Allocator > Iterator for Drain < ' _ , T , A >
161+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
155162 type Item = T ;
156163
157164 #[ inline]
@@ -165,20 +172,24 @@ impl<T, A: Allocator> Iterator for Drain<'_, T, A> {
165172}
166173
167174#[ stable( feature = "drain" , since = "1.6.0" ) ]
168- impl < T , A : Allocator > DoubleEndedIterator for Drain < ' _ , T , A > {
175+ impl < T , A : Allocator > DoubleEndedIterator for Drain < ' _ , T , A >
176+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
169177 #[ inline]
170178 fn next_back ( & mut self ) -> Option < T > {
171179 self . iter . next_back ( ) . map ( |elt| unsafe { ptr:: read ( elt as * const _ ) } )
172180 }
173181}
174182
175183#[ stable( feature = "drain" , since = "1.6.0" ) ]
176- impl < T , A : Allocator > Drop for Drain < ' _ , T , A > {
184+ impl < T , A : Allocator > Drop for Drain < ' _ , T , A >
185+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
177186 fn drop ( & mut self ) {
178187 /// Moves back the un-`Drain`ed elements to restore the original `Vec`.
179- struct DropGuard < ' r , ' a , T , A : Allocator > ( & ' r mut Drain < ' a , T , A > ) ;
188+ struct DropGuard < ' r , ' a , T , A : Allocator > ( & ' r mut Drain < ' a , T , A > )
189+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : ;
180190
181- impl < ' r , ' a , T , A : Allocator > Drop for DropGuard < ' r , ' a , T , A > {
191+ impl < ' r , ' a , T , A : Allocator > Drop for DropGuard < ' r , ' a , T , A >
192+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
182193 fn drop ( & mut self ) {
183194 if self . 0 . tail_len > 0 {
184195 unsafe {
@@ -242,14 +253,17 @@ impl<T, A: Allocator> Drop for Drain<'_, T, A> {
242253}
243254
244255#[ stable( feature = "drain" , since = "1.6.0" ) ]
245- impl < T , A : Allocator > ExactSizeIterator for Drain < ' _ , T , A > {
256+ impl < T , A : Allocator > ExactSizeIterator for Drain < ' _ , T , A >
257+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
246258 fn is_empty ( & self ) -> bool {
247259 self . iter . is_empty ( )
248260 }
249261}
250262
251263#[ unstable( feature = "trusted_len" , issue = "37572" ) ]
252- unsafe impl < T , A : Allocator > TrustedLen for Drain < ' _ , T , A > { }
264+ unsafe impl < T , A : Allocator > TrustedLen for Drain < ' _ , T , A >
265+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : { }
253266
254267#[ stable( feature = "fused" , since = "1.26.0" ) ]
255- impl < T , A : Allocator > FusedIterator for Drain < ' _ , T , A > { }
268+ impl < T , A : Allocator > FusedIterator for Drain < ' _ , T , A >
269+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : { }
0 commit comments