55//! are not required to be copyable, and the queue will be sendable if the
66//! contained type is sendable.
77
8- #![ stable ( feature = "rust1" , since = "1.0.0" ) ]
8+ #![ feature( global_co_alloc ) ]
99
10+ #![ stable( feature = "rust1" , since = "1.0.0" ) ]
11+ use core:: alloc;
1012use core:: cmp:: { self , Ordering } ;
1113use core:: fmt;
1214use core:: hash:: { Hash , Hasher } ;
@@ -91,10 +93,13 @@ mod tests;
9193#[ cfg_attr( not( test) , rustc_diagnostic_item = "VecDeque" ) ]
9294#[ stable( feature = "rust1" , since = "1.0.0" ) ]
9395#[ rustc_insignificant_dtor]
96+ // @TODO
9497pub struct VecDeque <
9598 T ,
9699 #[ unstable( feature = "allocator_api" , issue = "32838" ) ] A : Allocator = Global ,
97- > {
100+ >
101+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] :
102+ {
98103 // `self[0]`, if it exists, is `buf[head]`.
99104 // `head < buf.capacity()`, unless `buf.capacity() == 0` when `head == 0`.
100105 head : usize ,
@@ -106,7 +111,8 @@ pub struct VecDeque<
106111}
107112
108113#[ stable( feature = "rust1" , since = "1.0.0" ) ]
109- impl < T : Clone , A : Allocator + Clone > Clone for VecDeque < T , A > {
114+ impl < T : Clone , A : Allocator + Clone > Clone for VecDeque < T , A >
115+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
110116 fn clone ( & self ) -> Self {
111117 let mut deq = Self :: with_capacity_in ( self . len ( ) , self . allocator ( ) . clone ( ) ) ;
112118 deq. extend ( self . iter ( ) . cloned ( ) ) ;
@@ -120,7 +126,8 @@ impl<T: Clone, A: Allocator + Clone> Clone for VecDeque<T, A> {
120126}
121127
122128#[ stable( feature = "rust1" , since = "1.0.0" ) ]
123- unsafe impl < #[ may_dangle] T , A : Allocator > Drop for VecDeque < T , A > {
129+ unsafe impl < #[ may_dangle] T , A : Allocator > Drop for VecDeque < T , A >
130+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
124131 fn drop ( & mut self ) {
125132 /// Runs the destructor for all items in the slice when it gets dropped (normally or
126133 /// during unwinding).
@@ -153,7 +160,8 @@ impl<T> Default for VecDeque<T> {
153160 }
154161}
155162
156- impl < T , A : Allocator > VecDeque < T , A > {
163+ impl < T , A : Allocator > VecDeque < T , A >
164+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
157165 /// Marginally more convenient
158166 #[ inline]
159167 fn ptr ( & self ) -> * mut T {
@@ -442,7 +450,8 @@ impl<T, A: Allocator> VecDeque<T, A> {
442450 mut iter : impl Iterator < Item = T > ,
443451 len : usize ,
444452 ) -> usize {
445- struct Guard < ' a , T , A : Allocator > {
453+ struct Guard < ' a , T , A : Allocator >
454+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
446455 deque : & ' a mut VecDeque < T , A > ,
447456 written : usize ,
448457 }
@@ -560,7 +569,8 @@ impl<T> VecDeque<T> {
560569 }
561570}
562571
563- impl < T , A : Allocator > VecDeque < T , A > {
572+ impl < T , A : Allocator > VecDeque < T , A >
573+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
564574 /// Creates an empty deque.
565575 ///
566576 /// # Examples
@@ -2593,7 +2603,8 @@ impl<T, A: Allocator> VecDeque<T, A> {
25932603 }
25942604}
25952605
2596- impl < T : Clone , A : Allocator > VecDeque < T , A > {
2606+ impl < T : Clone , A : Allocator > VecDeque < T , A >
2607+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
25972608 /// Modifies the deque in-place so that `len()` is equal to new_len,
25982609 /// either by removing excess elements from the back or by appending clones of `value`
25992610 /// to the back.
@@ -2638,7 +2649,8 @@ fn wrap_index(logical_index: usize, capacity: usize) -> usize {
26382649}
26392650
26402651#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2641- impl < T : PartialEq , A : Allocator > PartialEq for VecDeque < T , A > {
2652+ impl < T : PartialEq , A : Allocator > PartialEq for VecDeque < T , A >
2653+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
26422654 fn eq ( & self , other : & Self ) -> bool {
26432655 if self . len != other. len ( ) {
26442656 return false ;
@@ -2677,7 +2689,8 @@ impl<T: PartialEq, A: Allocator> PartialEq for VecDeque<T, A> {
26772689}
26782690
26792691#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2680- impl < T : Eq , A : Allocator > Eq for VecDeque < T , A > { }
2692+ impl < T : Eq , A : Allocator > Eq for VecDeque < T , A >
2693+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : { }
26812694
26822695__impl_slice_eq1 ! { [ ] VecDeque <T , A >, Vec <U , A >, }
26832696__impl_slice_eq1 ! { [ ] VecDeque <T , A >, & [ U ] , }
@@ -2687,22 +2700,25 @@ __impl_slice_eq1! { [const N: usize] VecDeque<T, A>, &[U; N], }
26872700__impl_slice_eq1 ! { [ const N : usize ] VecDeque <T , A >, & mut [ U ; N ] , }
26882701
26892702#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2690- impl < T : PartialOrd , A : Allocator > PartialOrd for VecDeque < T , A > {
2703+ impl < T : PartialOrd , A : Allocator > PartialOrd for VecDeque < T , A >
2704+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
26912705 fn partial_cmp ( & self , other : & Self ) -> Option < Ordering > {
26922706 self . iter ( ) . partial_cmp ( other. iter ( ) )
26932707 }
26942708}
26952709
26962710#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2697- impl < T : Ord , A : Allocator > Ord for VecDeque < T , A > {
2711+ impl < T : Ord , A : Allocator > Ord for VecDeque < T , A >
2712+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
26982713 #[ inline]
26992714 fn cmp ( & self , other : & Self ) -> Ordering {
27002715 self . iter ( ) . cmp ( other. iter ( ) )
27012716 }
27022717}
27032718
27042719#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2705- impl < T : Hash , A : Allocator > Hash for VecDeque < T , A > {
2720+ impl < T : Hash , A : Allocator > Hash for VecDeque < T , A >
2721+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
27062722 fn hash < H : Hasher > ( & self , state : & mut H ) {
27072723 state. write_length_prefix ( self . len ) ;
27082724 // It's not possible to use Hash::hash_slice on slices
@@ -2716,7 +2732,8 @@ impl<T: Hash, A: Allocator> Hash for VecDeque<T, A> {
27162732}
27172733
27182734#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2719- impl < T , A : Allocator > Index < usize > for VecDeque < T , A > {
2735+ impl < T , A : Allocator > Index < usize > for VecDeque < T , A >
2736+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
27202737 type Output = T ;
27212738
27222739 #[ inline]
@@ -2726,7 +2743,8 @@ impl<T, A: Allocator> Index<usize> for VecDeque<T, A> {
27262743}
27272744
27282745#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2729- impl < T , A : Allocator > IndexMut < usize > for VecDeque < T , A > {
2746+ impl < T , A : Allocator > IndexMut < usize > for VecDeque < T , A >
2747+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
27302748 #[ inline]
27312749 fn index_mut ( & mut self , index : usize ) -> & mut T {
27322750 self . get_mut ( index) . expect ( "Out of bounds access" )
@@ -2741,7 +2759,8 @@ impl<T> FromIterator<T> for VecDeque<T> {
27412759}
27422760
27432761#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2744- impl < T , A : Allocator > IntoIterator for VecDeque < T , A > {
2762+ impl < T , A : Allocator > IntoIterator for VecDeque < T , A >
2763+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
27452764 type Item = T ;
27462765 type IntoIter = IntoIter < T , A > ;
27472766
@@ -2753,7 +2772,8 @@ impl<T, A: Allocator> IntoIterator for VecDeque<T, A> {
27532772}
27542773
27552774#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2756- impl < ' a , T , A : Allocator > IntoIterator for & ' a VecDeque < T , A > {
2775+ impl < ' a , T , A : Allocator > IntoIterator for & ' a VecDeque < T , A >
2776+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
27572777 type Item = & ' a T ;
27582778 type IntoIter = Iter < ' a , T > ;
27592779
@@ -2763,7 +2783,8 @@ impl<'a, T, A: Allocator> IntoIterator for &'a VecDeque<T, A> {
27632783}
27642784
27652785#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2766- impl < ' a , T , A : Allocator > IntoIterator for & ' a mut VecDeque < T , A > {
2786+ impl < ' a , T , A : Allocator > IntoIterator for & ' a mut VecDeque < T , A >
2787+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
27672788 type Item = & ' a mut T ;
27682789 type IntoIter = IterMut < ' a , T > ;
27692790
@@ -2773,7 +2794,8 @@ impl<'a, T, A: Allocator> IntoIterator for &'a mut VecDeque<T, A> {
27732794}
27742795
27752796#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2776- impl < T , A : Allocator > Extend < T > for VecDeque < T , A > {
2797+ impl < T , A : Allocator > Extend < T > for VecDeque < T , A >
2798+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
27772799 fn extend < I : IntoIterator < Item = T > > ( & mut self , iter : I ) {
27782800 <Self as SpecExtend < T , I :: IntoIter > >:: spec_extend ( self , iter. into_iter ( ) ) ;
27792801 }
@@ -2790,7 +2812,8 @@ impl<T, A: Allocator> Extend<T> for VecDeque<T, A> {
27902812}
27912813
27922814#[ stable( feature = "extend_ref" , since = "1.2.0" ) ]
2793- impl < ' a , T : ' a + Copy , A : Allocator > Extend < & ' a T > for VecDeque < T , A > {
2815+ impl < ' a , T : ' a + Copy , A : Allocator > Extend < & ' a T > for VecDeque < T , A >
2816+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
27942817 fn extend < I : IntoIterator < Item = & ' a T > > ( & mut self , iter : I ) {
27952818 self . spec_extend ( iter. into_iter ( ) ) ;
27962819 }
@@ -2807,14 +2830,16 @@ impl<'a, T: 'a + Copy, A: Allocator> Extend<&'a T> for VecDeque<T, A> {
28072830}
28082831
28092832#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2810- impl < T : fmt:: Debug , A : Allocator > fmt:: Debug for VecDeque < T , A > {
2833+ impl < T : fmt:: Debug , A : Allocator > fmt:: Debug for VecDeque < T , A >
2834+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
28112835 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
28122836 f. debug_list ( ) . entries ( self . iter ( ) ) . finish ( )
28132837 }
28142838}
28152839
28162840#[ stable( feature = "vecdeque_vec_conversions" , since = "1.10.0" ) ]
2817- impl < T , A : Allocator > From < Vec < T , A > > for VecDeque < T , A > {
2841+ impl < T , A : Allocator > From < Vec < T , A > > for VecDeque < T , A >
2842+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
28182843 /// Turn a [`Vec<T>`] into a [`VecDeque<T>`].
28192844 ///
28202845 /// [`Vec<T>`]: crate::vec::Vec
@@ -2831,7 +2856,8 @@ impl<T, A: Allocator> From<Vec<T, A>> for VecDeque<T, A> {
28312856}
28322857
28332858#[ stable( feature = "vecdeque_vec_conversions" , since = "1.10.0" ) ]
2834- impl < T , A : Allocator > From < VecDeque < T , A > > for Vec < T , A > {
2859+ impl < T , A : Allocator > From < VecDeque < T , A > > for Vec < T , A >
2860+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
28352861 /// Turn a [`VecDeque<T>`] into a [`Vec<T>`].
28362862 ///
28372863 /// [`Vec<T>`]: crate::vec::Vec
0 commit comments