5
5
//! are not required to be copyable, and the queue will be sendable if the
6
6
//! contained type is sendable.
7
7
8
- #![ stable ( feature = "rust1" , since = "1.0.0" ) ]
8
+ #![ feature( global_co_alloc ) ]
9
9
10
+ #![ stable( feature = "rust1" , since = "1.0.0" ) ]
11
+ use core:: alloc;
10
12
use core:: cmp:: { self , Ordering } ;
11
13
use core:: fmt;
12
14
use core:: hash:: { Hash , Hasher } ;
@@ -91,10 +93,13 @@ mod tests;
91
93
#[ cfg_attr( not( test) , rustc_diagnostic_item = "VecDeque" ) ]
92
94
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
93
95
#[ rustc_insignificant_dtor]
96
+ // @TODO
94
97
pub struct VecDeque <
95
98
T ,
96
99
#[ unstable( feature = "allocator_api" , issue = "32838" ) ] A : Allocator = Global ,
97
- > {
100
+ >
101
+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] :
102
+ {
98
103
// `self[0]`, if it exists, is `buf[head]`.
99
104
// `head < buf.capacity()`, unless `buf.capacity() == 0` when `head == 0`.
100
105
head : usize ,
@@ -106,7 +111,8 @@ pub struct VecDeque<
106
111
}
107
112
108
113
#[ 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 > ( ) ] : {
110
116
fn clone ( & self ) -> Self {
111
117
let mut deq = Self :: with_capacity_in ( self . len ( ) , self . allocator ( ) . clone ( ) ) ;
112
118
deq. extend ( self . iter ( ) . cloned ( ) ) ;
@@ -120,7 +126,8 @@ impl<T: Clone, A: Allocator + Clone> Clone for VecDeque<T, A> {
120
126
}
121
127
122
128
#[ 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 > ( ) ] : {
124
131
fn drop ( & mut self ) {
125
132
/// Runs the destructor for all items in the slice when it gets dropped (normally or
126
133
/// during unwinding).
@@ -153,7 +160,8 @@ impl<T> Default for VecDeque<T> {
153
160
}
154
161
}
155
162
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 > ( ) ] : {
157
165
/// Marginally more convenient
158
166
#[ inline]
159
167
fn ptr ( & self ) -> * mut T {
@@ -442,7 +450,8 @@ impl<T, A: Allocator> VecDeque<T, A> {
442
450
mut iter : impl Iterator < Item = T > ,
443
451
len : usize ,
444
452
) -> usize {
445
- struct Guard < ' a , T , A : Allocator > {
453
+ struct Guard < ' a , T , A : Allocator >
454
+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
446
455
deque : & ' a mut VecDeque < T , A > ,
447
456
written : usize ,
448
457
}
@@ -561,7 +570,8 @@ impl<T> VecDeque<T> {
561
570
}
562
571
}
563
572
564
- impl < T , A : Allocator > VecDeque < T , A > {
573
+ impl < T , A : Allocator > VecDeque < T , A >
574
+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
565
575
/// Creates an empty deque.
566
576
///
567
577
/// # Examples
@@ -2596,7 +2606,8 @@ impl<T, A: Allocator> VecDeque<T, A> {
2596
2606
}
2597
2607
}
2598
2608
2599
- impl < T : Clone , A : Allocator > VecDeque < T , A > {
2609
+ impl < T : Clone , A : Allocator > VecDeque < T , A >
2610
+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
2600
2611
/// Modifies the deque in-place so that `len()` is equal to new_len,
2601
2612
/// either by removing excess elements from the back or by appending clones of `value`
2602
2613
/// to the back.
@@ -2641,7 +2652,8 @@ fn wrap_index(logical_index: usize, capacity: usize) -> usize {
2641
2652
}
2642
2653
2643
2654
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2644
- impl < T : PartialEq , A : Allocator > PartialEq for VecDeque < T , A > {
2655
+ impl < T : PartialEq , A : Allocator > PartialEq for VecDeque < T , A >
2656
+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
2645
2657
fn eq ( & self , other : & Self ) -> bool {
2646
2658
if self . len != other. len ( ) {
2647
2659
return false ;
@@ -2680,7 +2692,8 @@ impl<T: PartialEq, A: Allocator> PartialEq for VecDeque<T, A> {
2680
2692
}
2681
2693
2682
2694
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2683
- impl < T : Eq , A : Allocator > Eq for VecDeque < T , A > { }
2695
+ impl < T : Eq , A : Allocator > Eq for VecDeque < T , A >
2696
+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : { }
2684
2697
2685
2698
__impl_slice_eq1 ! { [ ] VecDeque <T , A >, Vec <U , A >, }
2686
2699
__impl_slice_eq1 ! { [ ] VecDeque <T , A >, & [ U ] , }
@@ -2690,22 +2703,25 @@ __impl_slice_eq1! { [const N: usize] VecDeque<T, A>, &[U; N], }
2690
2703
__impl_slice_eq1 ! { [ const N : usize ] VecDeque <T , A >, & mut [ U ; N ] , }
2691
2704
2692
2705
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2693
- impl < T : PartialOrd , A : Allocator > PartialOrd for VecDeque < T , A > {
2706
+ impl < T : PartialOrd , A : Allocator > PartialOrd for VecDeque < T , A >
2707
+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
2694
2708
fn partial_cmp ( & self , other : & Self ) -> Option < Ordering > {
2695
2709
self . iter ( ) . partial_cmp ( other. iter ( ) )
2696
2710
}
2697
2711
}
2698
2712
2699
2713
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2700
- impl < T : Ord , A : Allocator > Ord for VecDeque < T , A > {
2714
+ impl < T : Ord , A : Allocator > Ord for VecDeque < T , A >
2715
+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
2701
2716
#[ inline]
2702
2717
fn cmp ( & self , other : & Self ) -> Ordering {
2703
2718
self . iter ( ) . cmp ( other. iter ( ) )
2704
2719
}
2705
2720
}
2706
2721
2707
2722
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2708
- impl < T : Hash , A : Allocator > Hash for VecDeque < T , A > {
2723
+ impl < T : Hash , A : Allocator > Hash for VecDeque < T , A >
2724
+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
2709
2725
fn hash < H : Hasher > ( & self , state : & mut H ) {
2710
2726
state. write_length_prefix ( self . len ) ;
2711
2727
// It's not possible to use Hash::hash_slice on slices
@@ -2719,7 +2735,8 @@ impl<T: Hash, A: Allocator> Hash for VecDeque<T, A> {
2719
2735
}
2720
2736
2721
2737
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2722
- impl < T , A : Allocator > Index < usize > for VecDeque < T , A > {
2738
+ impl < T , A : Allocator > Index < usize > for VecDeque < T , A >
2739
+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
2723
2740
type Output = T ;
2724
2741
2725
2742
#[ inline]
@@ -2729,7 +2746,8 @@ impl<T, A: Allocator> Index<usize> for VecDeque<T, A> {
2729
2746
}
2730
2747
2731
2748
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2732
- impl < T , A : Allocator > IndexMut < usize > for VecDeque < T , A > {
2749
+ impl < T , A : Allocator > IndexMut < usize > for VecDeque < T , A >
2750
+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
2733
2751
#[ inline]
2734
2752
fn index_mut ( & mut self , index : usize ) -> & mut T {
2735
2753
self . get_mut ( index) . expect ( "Out of bounds access" )
@@ -2744,7 +2762,8 @@ impl<T> FromIterator<T> for VecDeque<T> {
2744
2762
}
2745
2763
2746
2764
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2747
- impl < T , A : Allocator > IntoIterator for VecDeque < T , A > {
2765
+ impl < T , A : Allocator > IntoIterator for VecDeque < T , A >
2766
+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
2748
2767
type Item = T ;
2749
2768
type IntoIter = IntoIter < T , A > ;
2750
2769
@@ -2756,7 +2775,8 @@ impl<T, A: Allocator> IntoIterator for VecDeque<T, A> {
2756
2775
}
2757
2776
2758
2777
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2759
- impl < ' a , T , A : Allocator > IntoIterator for & ' a VecDeque < T , A > {
2778
+ impl < ' a , T , A : Allocator > IntoIterator for & ' a VecDeque < T , A >
2779
+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
2760
2780
type Item = & ' a T ;
2761
2781
type IntoIter = Iter < ' a , T > ;
2762
2782
@@ -2766,7 +2786,8 @@ impl<'a, T, A: Allocator> IntoIterator for &'a VecDeque<T, A> {
2766
2786
}
2767
2787
2768
2788
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2769
- impl < ' a , T , A : Allocator > IntoIterator for & ' a mut VecDeque < T , A > {
2789
+ impl < ' a , T , A : Allocator > IntoIterator for & ' a mut VecDeque < T , A >
2790
+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
2770
2791
type Item = & ' a mut T ;
2771
2792
type IntoIter = IterMut < ' a , T > ;
2772
2793
@@ -2776,7 +2797,8 @@ impl<'a, T, A: Allocator> IntoIterator for &'a mut VecDeque<T, A> {
2776
2797
}
2777
2798
2778
2799
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2779
- impl < T , A : Allocator > Extend < T > for VecDeque < T , A > {
2800
+ impl < T , A : Allocator > Extend < T > for VecDeque < T , A >
2801
+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
2780
2802
fn extend < I : IntoIterator < Item = T > > ( & mut self , iter : I ) {
2781
2803
<Self as SpecExtend < T , I :: IntoIter > >:: spec_extend ( self , iter. into_iter ( ) ) ;
2782
2804
}
@@ -2793,7 +2815,8 @@ impl<T, A: Allocator> Extend<T> for VecDeque<T, A> {
2793
2815
}
2794
2816
2795
2817
#[ stable( feature = "extend_ref" , since = "1.2.0" ) ]
2796
- impl < ' a , T : ' a + Copy , A : Allocator > Extend < & ' a T > for VecDeque < T , A > {
2818
+ impl < ' a , T : ' a + Copy , A : Allocator > Extend < & ' a T > for VecDeque < T , A >
2819
+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
2797
2820
fn extend < I : IntoIterator < Item = & ' a T > > ( & mut self , iter : I ) {
2798
2821
self . spec_extend ( iter. into_iter ( ) ) ;
2799
2822
}
@@ -2810,14 +2833,16 @@ impl<'a, T: 'a + Copy, A: Allocator> Extend<&'a T> for VecDeque<T, A> {
2810
2833
}
2811
2834
2812
2835
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2813
- impl < T : fmt:: Debug , A : Allocator > fmt:: Debug for VecDeque < T , A > {
2836
+ impl < T : fmt:: Debug , A : Allocator > fmt:: Debug for VecDeque < T , A >
2837
+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
2814
2838
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
2815
2839
f. debug_list ( ) . entries ( self . iter ( ) ) . finish ( )
2816
2840
}
2817
2841
}
2818
2842
2819
2843
#[ stable( feature = "vecdeque_vec_conversions" , since = "1.10.0" ) ]
2820
- impl < T , A : Allocator > From < Vec < T , A > > for VecDeque < T , A > {
2844
+ impl < T , A : Allocator > From < Vec < T , A > > for VecDeque < T , A >
2845
+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
2821
2846
/// Turn a [`Vec<T>`] into a [`VecDeque<T>`].
2822
2847
///
2823
2848
/// [`Vec<T>`]: crate::vec::Vec
@@ -2834,7 +2859,8 @@ impl<T, A: Allocator> From<Vec<T, A>> for VecDeque<T, A> {
2834
2859
}
2835
2860
2836
2861
#[ stable( feature = "vecdeque_vec_conversions" , since = "1.10.0" ) ]
2837
- impl < T , A : Allocator > From < VecDeque < T , A > > for Vec < T , A > {
2862
+ impl < T , A : Allocator > From < VecDeque < T , A > > for Vec < T , A >
2863
+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
2838
2864
/// Turn a [`VecDeque<T>`] into a [`Vec<T>`].
2839
2865
///
2840
2866
/// [`Vec<T>`]: crate::vec::Vec
0 commit comments