@@ -91,14 +91,6 @@ pub trait Append {
91
91
fn is_empty ( & self ) -> bool ;
92
92
}
93
93
94
- impl Append for ( ) {
95
- fn append ( & mut self , _other : Self ) { }
96
-
97
- fn is_empty ( & self ) -> bool {
98
- true
99
- }
100
- }
101
-
102
94
impl < K : Ord , V > Append for BTreeMap < K , V > {
103
95
fn append ( & mut self , mut other : Self ) {
104
96
BTreeMap :: append ( self , & mut other)
@@ -129,13 +121,30 @@ impl<T> Append for Vec<T> {
129
121
}
130
122
}
131
123
132
- impl < A : Append , B : Append > Append for ( A , B ) {
133
- fn append ( & mut self , other : Self ) {
134
- Append :: append ( & mut self . 0 , other. 0 ) ;
135
- Append :: append ( & mut self . 1 , other. 1 ) ;
136
- }
124
+ macro_rules! impl_append_for_tuple {
125
+ ( $( $a: ident $b: tt) * ) => {
126
+ impl <$( $a) ,* > Append for ( $( $a, ) * ) where $( $a: Append ) ,* {
137
127
138
- fn is_empty ( & self ) -> bool {
139
- Append :: is_empty ( & self . 0 ) && Append :: is_empty ( & self . 1 )
128
+ fn append( & mut self , _other: Self ) {
129
+ $( Append :: append( & mut self . $b, _other. $b) ) ;*
130
+ }
131
+
132
+ fn is_empty( & self ) -> bool {
133
+ $( Append :: is_empty( & self . $b) && ) * true
134
+ }
135
+ }
140
136
}
141
137
}
138
+
139
+ impl_append_for_tuple ! ( ) ;
140
+ impl_append_for_tuple ! ( T0 0 ) ;
141
+ impl_append_for_tuple ! ( T0 0 T1 1 ) ;
142
+ impl_append_for_tuple ! ( T0 0 T1 1 T2 2 ) ;
143
+ impl_append_for_tuple ! ( T0 0 T1 1 T2 2 T3 3 ) ;
144
+ impl_append_for_tuple ! ( T0 0 T1 1 T2 2 T3 3 T4 4 ) ;
145
+ impl_append_for_tuple ! ( T0 0 T1 1 T2 2 T3 3 T4 4 T5 5 ) ;
146
+ impl_append_for_tuple ! ( T0 0 T1 1 T2 2 T3 3 T4 4 T5 5 T6 6 ) ;
147
+ impl_append_for_tuple ! ( T0 0 T1 1 T2 2 T3 3 T4 4 T5 5 T6 6 T7 7 ) ;
148
+ impl_append_for_tuple ! ( T0 0 T1 1 T2 2 T3 3 T4 4 T5 5 T6 6 T7 7 T8 8 ) ;
149
+ impl_append_for_tuple ! ( T0 0 T1 1 T2 2 T3 3 T4 4 T5 5 T6 6 T7 7 T8 8 T9 9 ) ;
150
+ impl_append_for_tuple ! ( T0 0 T1 1 T2 2 T3 3 T4 4 T5 5 T6 6 T7 7 T8 8 T9 9 T10 10 ) ;
0 commit comments