@@ -2,6 +2,8 @@ use core::iter::FusedIterator;
22use core:: ptr:: { self , NonNull } ;
33use core:: { fmt, mem} ;
44
5+ use crate :: alloc:: { Allocator , Global } ;
6+
57use super :: { count, Iter , VecDeque } ;
68
79/// A draining iterator over the elements of a `VecDeque`.
@@ -11,15 +13,15 @@ use super::{count, Iter, VecDeque};
1113///
1214/// [`drain`]: VecDeque::drain
1315#[ stable( feature = "drain" , since = "1.6.0" ) ]
14- pub struct Drain < ' a , T : ' a > {
16+ pub struct Drain < ' a , T : ' a , A : Allocator = Global > {
1517 pub ( crate ) after_tail : usize ,
1618 pub ( crate ) after_head : usize ,
1719 pub ( crate ) iter : Iter < ' a , T > ,
18- pub ( crate ) deque : NonNull < VecDeque < T > > ,
20+ pub ( crate ) deque : NonNull < VecDeque < T , A > > ,
1921}
2022
2123#[ stable( feature = "collection_debug" , since = "1.17.0" ) ]
22- impl < T : fmt:: Debug > fmt:: Debug for Drain < ' _ , T > {
24+ impl < T : fmt:: Debug , A : Allocator > fmt:: Debug for Drain < ' _ , T , A > {
2325 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
2426 f. debug_tuple ( "Drain" )
2527 . field ( & self . after_tail )
@@ -30,16 +32,16 @@ impl<T: fmt::Debug> fmt::Debug for Drain<'_, T> {
3032}
3133
3234#[ stable( feature = "drain" , since = "1.6.0" ) ]
33- unsafe impl < T : Sync > Sync for Drain < ' _ , T > { }
35+ unsafe impl < T : Sync , A : Allocator + Sync > Sync for Drain < ' _ , T , A > { }
3436#[ stable( feature = "drain" , since = "1.6.0" ) ]
35- unsafe impl < T : Send > Send for Drain < ' _ , T > { }
37+ unsafe impl < T : Send , A : Allocator + Send > Send for Drain < ' _ , T , A > { }
3638
3739#[ stable( feature = "drain" , since = "1.6.0" ) ]
38- impl < T > Drop for Drain < ' _ , T > {
40+ impl < T , A : Allocator > Drop for Drain < ' _ , T , A > {
3941 fn drop ( & mut self ) {
40- struct DropGuard < ' r , ' a , T > ( & ' r mut Drain < ' a , T > ) ;
42+ struct DropGuard < ' r , ' a , T , A : Allocator > ( & ' r mut Drain < ' a , T , A > ) ;
4143
42- impl < ' r , ' a , T > Drop for DropGuard < ' r , ' a , T > {
44+ impl < ' r , ' a , T , A : Allocator > Drop for DropGuard < ' r , ' a , T , A > {
4345 fn drop ( & mut self ) {
4446 self . 0 . for_each ( drop) ;
4547
@@ -96,7 +98,7 @@ impl<T> Drop for Drain<'_, T> {
9698}
9799
98100#[ stable( feature = "drain" , since = "1.6.0" ) ]
99- impl < T > Iterator for Drain < ' _ , T > {
101+ impl < T , A : Allocator > Iterator for Drain < ' _ , T , A > {
100102 type Item = T ;
101103
102104 #[ inline]
@@ -111,15 +113,15 @@ impl<T> Iterator for Drain<'_, T> {
111113}
112114
113115#[ stable( feature = "drain" , since = "1.6.0" ) ]
114- impl < T > DoubleEndedIterator for Drain < ' _ , T > {
116+ impl < T , A : Allocator > DoubleEndedIterator for Drain < ' _ , T , A > {
115117 #[ inline]
116118 fn next_back ( & mut self ) -> Option < T > {
117119 self . iter . next_back ( ) . map ( |elt| unsafe { ptr:: read ( elt) } )
118120 }
119121}
120122
121123#[ stable( feature = "drain" , since = "1.6.0" ) ]
122- impl < T > ExactSizeIterator for Drain < ' _ , T > { }
124+ impl < T , A : Allocator > ExactSizeIterator for Drain < ' _ , T , A > { }
123125
124126#[ stable( feature = "fused" , since = "1.26.0" ) ]
125- impl < T > FusedIterator for Drain < ' _ , T > { }
127+ impl < T , A : Allocator > FusedIterator for Drain < ' _ , T , A > { }
0 commit comments