@@ -3,28 +3,39 @@ use crate::Array;
3
3
use crate :: SmallVec ;
4
4
use core:: ptr;
5
5
6
+ macro_rules! create_with_parts {
7
+ (
8
+ <$( $( { $s_impl_ty_prefix: ident} ) ? $s_impl_ty: ident$( : $s_impl_ty_bound: ident) ?) ,* >,
9
+ <$s_decl_ty: ident$( , { $s_decl_const_ty: ident} ) ?>,
10
+ $array_item: ty
11
+ ) => {
12
+
6
13
/// An iterator that consumes a `SmallVec` and yields its items by value.
7
14
///
8
15
/// Returned from [`SmallVec::into_iter`][1].
9
16
///
10
17
/// [1]: struct.SmallVec.html#method.into_iter
11
- pub struct IntoIter < A : Array > {
12
- pub ( crate ) data : SmallVec < A > ,
18
+ pub struct IntoIter <$ ( $ ( $s_impl_ty_prefix ) ? $s_impl_ty$ ( : $s_impl_ty_bound ) ? ) , * > {
19
+ pub ( crate ) data: SmallVec <$s_decl_ty$ ( , { $s_decl_const_ty } ) ? >,
13
20
pub ( crate ) current: usize ,
14
21
pub ( crate ) end: usize ,
15
22
}
16
23
17
- impl < A : Array > Drop for IntoIter < A > {
24
+ impl <$( $( $s_impl_ty_prefix) ? $s_impl_ty$( : $s_impl_ty_bound) ?) ,* > Drop
25
+ for IntoIter <$s_decl_ty$( , { $s_decl_const_ty} ) ?>
26
+ {
18
27
fn drop( & mut self ) {
19
28
for _ in self { }
20
29
}
21
30
}
22
31
23
- impl < A : Array > Iterator for IntoIter < A > {
24
- type Item = A :: Item ;
32
+ impl <$( $( $s_impl_ty_prefix) ? $s_impl_ty$( : $s_impl_ty_bound) ?) ,* > Iterator
33
+ for IntoIter <$s_decl_ty$( , { $s_decl_const_ty} ) ?>
34
+ {
35
+ type Item = $array_item;
25
36
26
37
#[ inline]
27
- fn next ( & mut self ) -> Option < A :: Item > {
38
+ fn next( & mut self ) -> Option <$array_item > {
28
39
if self . current == self . end {
29
40
None
30
41
} else {
@@ -43,9 +54,11 @@ impl<A: Array> Iterator for IntoIter<A> {
43
54
}
44
55
}
45
56
46
- impl < A : Array > DoubleEndedIterator for IntoIter < A > {
57
+ impl <$( $( $s_impl_ty_prefix) ? $s_impl_ty$( : $s_impl_ty_bound) ?) ,* > DoubleEndedIterator
58
+ for IntoIter <$s_decl_ty$( , { $s_decl_const_ty} ) ?>
59
+ {
47
60
#[ inline]
48
- fn next_back ( & mut self ) -> Option < A :: Item > {
61
+ fn next_back( & mut self ) -> Option <$array_item > {
49
62
if self . current == self . end {
50
63
None
51
64
} else {
@@ -57,4 +70,13 @@ impl<A: Array> DoubleEndedIterator for IntoIter<A> {
57
70
}
58
71
}
59
72
60
- impl < A : Array > ExactSizeIterator for IntoIter < A > { }
73
+ impl <$( $( $s_impl_ty_prefix) ? $s_impl_ty$( : $s_impl_ty_bound) ?) ,* > ExactSizeIterator
74
+ for IntoIter <$s_decl_ty$( , { $s_decl_const_ty} ) ?> { }
75
+
76
+ }
77
+ }
78
+
79
+ #[ cfg( feature = "const_generics" ) ]
80
+ create_with_parts ! ( <T , { const } N : usize >, <T , { N } >, T ) ;
81
+ #[ cfg( not( feature = "const_generics" ) ) ]
82
+ create_with_parts ! ( <A : Array >, <A >, A :: Item ) ;
0 commit comments