@@ -235,6 +235,46 @@ macro_rules! tuple_impl {
235
235
} ;
236
236
}
237
237
238
+ impl < T : Value > Value for ( T , ) {
239
+ type SelfType < ' a >
240
+ = ( T :: SelfType < ' a > , )
241
+ where
242
+ Self : ' a ;
243
+ type AsBytes < ' a >
244
+ = T :: AsBytes < ' a >
245
+ where
246
+ Self : ' a ;
247
+
248
+ fn fixed_width ( ) -> Option < usize > {
249
+ T :: fixed_width ( )
250
+ }
251
+
252
+ fn from_bytes < ' a > ( data : & ' a [ u8 ] ) -> Self :: SelfType < ' a >
253
+ where
254
+ Self : ' a ,
255
+ {
256
+ ( T :: from_bytes ( data) , )
257
+ }
258
+
259
+ fn as_bytes < ' a , ' b : ' a > ( value : & ' a Self :: SelfType < ' b > ) -> Self :: AsBytes < ' a >
260
+ where
261
+ Self : ' a ,
262
+ Self : ' b ,
263
+ {
264
+ T :: as_bytes ( & value. 0 )
265
+ }
266
+
267
+ fn type_name ( ) -> TypeName {
268
+ TypeName :: internal ( & format ! ( "({},)" , T :: type_name( ) . name( ) ) )
269
+ }
270
+ }
271
+
272
+ impl < T : Key > Key for ( T , ) {
273
+ fn compare ( data1 : & [ u8 ] , data2 : & [ u8 ] ) -> Ordering {
274
+ T :: compare ( data1, data2)
275
+ }
276
+ }
277
+
238
278
tuple_impl ! {
239
279
T0 , t0, 0
240
280
| T1 , t1, 1
@@ -353,6 +393,7 @@ mod test {
353
393
fn width ( ) {
354
394
assert ! ( <( & str , u8 ) >:: fixed_width( ) . is_none( ) ) ;
355
395
assert ! ( <( u16 , u8 , & str , u128 ) >:: fixed_width( ) . is_none( ) ) ;
396
+ assert_eq ! ( <( u16 , ) >:: fixed_width( ) . unwrap( ) , 2 ) ;
356
397
assert_eq ! ( <( u16 , u8 ) >:: fixed_width( ) . unwrap( ) , 3 ) ;
357
398
assert_eq ! ( <( u16 , u8 , u128 ) >:: fixed_width( ) . unwrap( ) , 19 ) ;
358
399
assert_eq ! ( <( u16 , u8 , i8 , u128 ) >:: fixed_width( ) . unwrap( ) , 20 ) ;
0 commit comments