@@ -19,11 +19,12 @@ 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 }
2223>
23- where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
24+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots_with_preference :: < A > ( COOP_PREFERRED ) ] : {
2425 // We can't just use a &mut VecDeque<T, A>, as that would make Drain invariant over T
2526 // and we want it to be covariant instead
26- deque : NonNull < VecDeque < T , A > > ,
27+ deque : NonNull < VecDeque < T , A , COOP_PREFERRED > > ,
2728 // drain_start is stored in deque.len
2829 drain_len : usize ,
2930 // index into the logical array, not the physical one (always lies in [0..deque.len))
@@ -35,10 +36,10 @@ where [(); alloc::co_alloc_metadata_num_slots::<A>()]: {
3536 _marker : PhantomData < & ' a T > ,
3637}
3738
38- impl < ' a , T , A : Allocator > Drain < ' a , T , A >
39- where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
39+ 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 ) ] : {
4041 pub ( super ) unsafe fn new (
41- deque : & ' a mut VecDeque < T , A > ,
42+ deque : & ' a mut VecDeque < T , A , COOP_PREFERRED > ,
4243 drain_start : usize ,
4344 drain_len : usize ,
4445 ) -> Self {
@@ -90,8 +91,8 @@ where [(); alloc::co_alloc_metadata_num_slots::<A>()]: {
9091}
9192
9293#[ stable( feature = "collection_debug" , since = "1.17.0" ) ]
93- impl < T : fmt:: Debug , A : Allocator > fmt:: Debug for Drain < ' _ , T , A >
94- where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
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 ) ] : {
9596 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
9697 f. debug_tuple ( "Drain" )
9798 . field ( & self . drain_len )
@@ -103,21 +104,21 @@ where [(); alloc::co_alloc_metadata_num_slots::<A>()]: {
103104}
104105
105106#[ stable( feature = "drain" , since = "1.6.0" ) ]
106- unsafe impl < T : Sync , A : Allocator + Sync > Sync for Drain < ' _ , T , A >
107- where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : { }
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 ) ] : { }
108109#[ stable( feature = "drain" , since = "1.6.0" ) ]
109- unsafe impl < T : Send , A : Allocator + Send > Send for Drain < ' _ , T , A >
110- where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : { }
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 ) ] : { }
111112
112113#[ stable( feature = "drain" , since = "1.6.0" ) ]
113- impl < T , A : Allocator > Drop for Drain < ' _ , T , A >
114- where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
114+ 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 ) ] : {
115116 fn drop ( & mut self ) {
116- struct DropGuard < ' r , ' a , T , A : Allocator > ( & ' r mut Drain < ' a , T , A > )
117- where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : ;
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 ) ] : ;
118119
119- impl < ' r , ' a , T , A : Allocator > Drop for DropGuard < ' r , ' a , T , A >
120- where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
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 ) ] : {
121122 fn drop ( & mut self ) {
122123 if self . 0 . remaining != 0 {
123124 unsafe {
@@ -198,8 +199,8 @@ where [(); alloc::co_alloc_metadata_num_slots::<A>()]: {
198199}
199200
200201#[ stable( feature = "drain" , since = "1.6.0" ) ]
201- impl < T , A : Allocator > Iterator for Drain < ' _ , T , A >
202- where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
202+ 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 ) ] : {
203204 type Item = T ;
204205
205206 #[ inline]
@@ -221,8 +222,8 @@ where [(); alloc::co_alloc_metadata_num_slots::<A>()]: {
221222}
222223
223224#[ stable( feature = "drain" , since = "1.6.0" ) ]
224- impl < T , A : Allocator > DoubleEndedIterator for Drain < ' _ , T , A >
225- where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
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 ) ] : {
226227 #[ inline]
227228 fn next_back ( & mut self ) -> Option < T > {
228229 if self . remaining == 0 {
@@ -235,9 +236,9 @@ where [(); alloc::co_alloc_metadata_num_slots::<A>()]: {
235236}
236237
237238#[ stable( feature = "drain" , since = "1.6.0" ) ]
238- impl < T , A : Allocator > ExactSizeIterator for Drain < ' _ , T , A >
239- where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : { }
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 ) ] : { }
240241
241242#[ stable( feature = "fused" , since = "1.26.0" ) ]
242- impl < T , A : Allocator > FusedIterator for Drain < ' _ , T , A >
243- where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : { }
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 ) ] : { }
0 commit comments