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
@@ -2594,7 +2604,8 @@ impl<T, A: Allocator> VecDeque<T, A> {
2594
2604
}
2595
2605
}
2596
2606
2597
- impl < T : Clone , A : Allocator > VecDeque < T , A > {
2607
+ impl < T : Clone , A : Allocator > VecDeque < T , A >
2608
+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
2598
2609
/// Modifies the deque in-place so that `len()` is equal to new_len,
2599
2610
/// either by removing excess elements from the back or by appending clones of `value`
2600
2611
/// to the back.
@@ -2639,7 +2650,8 @@ fn wrap_index(logical_index: usize, capacity: usize) -> usize {
2639
2650
}
2640
2651
2641
2652
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2642
- impl < T : PartialEq , A : Allocator > PartialEq for VecDeque < T , A > {
2653
+ impl < T : PartialEq , A : Allocator > PartialEq for VecDeque < T , A >
2654
+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
2643
2655
fn eq ( & self , other : & Self ) -> bool {
2644
2656
if self . len != other. len ( ) {
2645
2657
return false ;
@@ -2678,7 +2690,8 @@ impl<T: PartialEq, A: Allocator> PartialEq for VecDeque<T, A> {
2678
2690
}
2679
2691
2680
2692
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2681
- impl < T : Eq , A : Allocator > Eq for VecDeque < T , A > { }
2693
+ impl < T : Eq , A : Allocator > Eq for VecDeque < T , A >
2694
+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : { }
2682
2695
2683
2696
__impl_slice_eq1 ! { [ ] VecDeque <T , A >, Vec <U , A >, }
2684
2697
__impl_slice_eq1 ! { [ ] VecDeque <T , A >, & [ U ] , }
@@ -2688,22 +2701,25 @@ __impl_slice_eq1! { [const N: usize] VecDeque<T, A>, &[U; N], }
2688
2701
__impl_slice_eq1 ! { [ const N : usize ] VecDeque <T , A >, & mut [ U ; N ] , }
2689
2702
2690
2703
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2691
- impl < T : PartialOrd , A : Allocator > PartialOrd for VecDeque < T , A > {
2704
+ impl < T : PartialOrd , A : Allocator > PartialOrd for VecDeque < T , A >
2705
+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
2692
2706
fn partial_cmp ( & self , other : & Self ) -> Option < Ordering > {
2693
2707
self . iter ( ) . partial_cmp ( other. iter ( ) )
2694
2708
}
2695
2709
}
2696
2710
2697
2711
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2698
- impl < T : Ord , A : Allocator > Ord for VecDeque < T , A > {
2712
+ impl < T : Ord , A : Allocator > Ord for VecDeque < T , A >
2713
+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
2699
2714
#[ inline]
2700
2715
fn cmp ( & self , other : & Self ) -> Ordering {
2701
2716
self . iter ( ) . cmp ( other. iter ( ) )
2702
2717
}
2703
2718
}
2704
2719
2705
2720
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2706
- impl < T : Hash , A : Allocator > Hash for VecDeque < T , A > {
2721
+ impl < T : Hash , A : Allocator > Hash for VecDeque < T , A >
2722
+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
2707
2723
fn hash < H : Hasher > ( & self , state : & mut H ) {
2708
2724
state. write_length_prefix ( self . len ) ;
2709
2725
// It's not possible to use Hash::hash_slice on slices
@@ -2717,7 +2733,8 @@ impl<T: Hash, A: Allocator> Hash for VecDeque<T, A> {
2717
2733
}
2718
2734
2719
2735
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2720
- impl < T , A : Allocator > Index < usize > for VecDeque < T , A > {
2736
+ impl < T , A : Allocator > Index < usize > for VecDeque < T , A >
2737
+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
2721
2738
type Output = T ;
2722
2739
2723
2740
#[ inline]
@@ -2727,7 +2744,8 @@ impl<T, A: Allocator> Index<usize> for VecDeque<T, A> {
2727
2744
}
2728
2745
2729
2746
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2730
- impl < T , A : Allocator > IndexMut < usize > for VecDeque < T , A > {
2747
+ impl < T , A : Allocator > IndexMut < usize > for VecDeque < T , A >
2748
+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
2731
2749
#[ inline]
2732
2750
fn index_mut ( & mut self , index : usize ) -> & mut T {
2733
2751
self . get_mut ( index) . expect ( "Out of bounds access" )
@@ -2742,7 +2760,8 @@ impl<T> FromIterator<T> for VecDeque<T> {
2742
2760
}
2743
2761
2744
2762
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2745
- impl < T , A : Allocator > IntoIterator for VecDeque < T , A > {
2763
+ impl < T , A : Allocator > IntoIterator for VecDeque < T , A >
2764
+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
2746
2765
type Item = T ;
2747
2766
type IntoIter = IntoIter < T , A > ;
2748
2767
@@ -2754,7 +2773,8 @@ impl<T, A: Allocator> IntoIterator for VecDeque<T, A> {
2754
2773
}
2755
2774
2756
2775
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2757
- impl < ' a , T , A : Allocator > IntoIterator for & ' a VecDeque < T , A > {
2776
+ impl < ' a , T , A : Allocator > IntoIterator for & ' a VecDeque < T , A >
2777
+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
2758
2778
type Item = & ' a T ;
2759
2779
type IntoIter = Iter < ' a , T > ;
2760
2780
@@ -2764,7 +2784,8 @@ impl<'a, T, A: Allocator> IntoIterator for &'a VecDeque<T, A> {
2764
2784
}
2765
2785
2766
2786
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2767
- impl < ' a , T , A : Allocator > IntoIterator for & ' a mut VecDeque < T , A > {
2787
+ impl < ' a , T , A : Allocator > IntoIterator for & ' a mut VecDeque < T , A >
2788
+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
2768
2789
type Item = & ' a mut T ;
2769
2790
type IntoIter = IterMut < ' a , T > ;
2770
2791
@@ -2774,7 +2795,8 @@ impl<'a, T, A: Allocator> IntoIterator for &'a mut VecDeque<T, A> {
2774
2795
}
2775
2796
2776
2797
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2777
- impl < T , A : Allocator > Extend < T > for VecDeque < T , A > {
2798
+ impl < T , A : Allocator > Extend < T > for VecDeque < T , A >
2799
+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
2778
2800
fn extend < I : IntoIterator < Item = T > > ( & mut self , iter : I ) {
2779
2801
<Self as SpecExtend < T , I :: IntoIter > >:: spec_extend ( self , iter. into_iter ( ) ) ;
2780
2802
}
@@ -2791,7 +2813,8 @@ impl<T, A: Allocator> Extend<T> for VecDeque<T, A> {
2791
2813
}
2792
2814
2793
2815
#[ stable( feature = "extend_ref" , since = "1.2.0" ) ]
2794
- impl < ' a , T : ' a + Copy , A : Allocator > Extend < & ' a T > for VecDeque < T , A > {
2816
+ impl < ' a , T : ' a + Copy , A : Allocator > Extend < & ' a T > for VecDeque < T , A >
2817
+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
2795
2818
fn extend < I : IntoIterator < Item = & ' a T > > ( & mut self , iter : I ) {
2796
2819
self . spec_extend ( iter. into_iter ( ) ) ;
2797
2820
}
@@ -2808,14 +2831,16 @@ impl<'a, T: 'a + Copy, A: Allocator> Extend<&'a T> for VecDeque<T, A> {
2808
2831
}
2809
2832
2810
2833
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2811
- impl < T : fmt:: Debug , A : Allocator > fmt:: Debug for VecDeque < T , A > {
2834
+ impl < T : fmt:: Debug , A : Allocator > fmt:: Debug for VecDeque < T , A >
2835
+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
2812
2836
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
2813
2837
f. debug_list ( ) . entries ( self . iter ( ) ) . finish ( )
2814
2838
}
2815
2839
}
2816
2840
2817
2841
#[ stable( feature = "vecdeque_vec_conversions" , since = "1.10.0" ) ]
2818
- impl < T , A : Allocator > From < Vec < T , A > > for VecDeque < T , A > {
2842
+ impl < T , A : Allocator > From < Vec < T , A > > for VecDeque < T , A >
2843
+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
2819
2844
/// Turn a [`Vec<T>`] into a [`VecDeque<T>`].
2820
2845
///
2821
2846
/// [`Vec<T>`]: crate::vec::Vec
@@ -2832,7 +2857,8 @@ impl<T, A: Allocator> From<Vec<T, A>> for VecDeque<T, A> {
2832
2857
}
2833
2858
2834
2859
#[ stable( feature = "vecdeque_vec_conversions" , since = "1.10.0" ) ]
2835
- impl < T , A : Allocator > From < VecDeque < T , A > > for Vec < T , A > {
2860
+ impl < T , A : Allocator > From < VecDeque < T , A > > for Vec < T , A >
2861
+ where [ ( ) ; alloc:: co_alloc_metadata_num_slots :: < A > ( ) ] : {
2836
2862
/// Turn a [`VecDeque<T>`] into a [`Vec<T>`].
2837
2863
///
2838
2864
/// [`Vec<T>`]: crate::vec::Vec
0 commit comments