@@ -5,6 +5,7 @@ use core::{
5
5
fmt:: Debug ,
6
6
ops:: { Add , Div , Mul , Neg , Sub } ,
7
7
} ;
8
+ use variadics_please:: all_tuples_enumerated;
8
9
9
10
/// A type that supports the mathematical operations of a real vector space, irrespective of dimension.
10
11
/// In particular, this means that the implementing type supports:
@@ -393,31 +394,9 @@ impl StableInterpolate for Dir3A {
393
394
}
394
395
}
395
396
396
- // If you're confused about how #[doc(fake_variadic)] works,
397
- // then the `all_tuples` macro is nicely documented (it can be found in the `bevy_utils` crate).
398
- // tl;dr: `#[doc(fake_variadic)]` goes on the impl of tuple length one.
399
- // the others have to be hidden using `#[doc(hidden)]`.
400
397
macro_rules! impl_stable_interpolate_tuple {
401
- ( ( $T: ident, $n: tt) ) => {
402
- impl_stable_interpolate_tuple! {
403
- @impl
404
- #[ cfg_attr( any( docsrs, docsrs_dep) , doc( fake_variadic) ) ]
405
- #[ cfg_attr(
406
- any( docsrs, docsrs_dep) ,
407
- doc = "This trait is implemented for tuples up to 11 items long."
408
- ) ]
409
- ( $T, $n)
410
- }
411
- } ;
412
- ( $( ( $T: ident, $n: tt) ) ,* ) => {
413
- impl_stable_interpolate_tuple! {
414
- @impl
415
- #[ cfg_attr( any( docsrs, docsrs_dep) , doc( hidden) ) ]
416
- $( ( $T, $n) ) ,*
417
- }
418
- } ;
419
- ( @impl $( #[ $( $meta: meta) * ] ) * $( ( $T: ident, $n: tt) ) ,* ) => {
420
- $( #[ $( $meta) * ] ) *
398
+ ( $( #[ $meta: meta] ) * $( ( $n: tt, $T: ident) ) ,* ) => {
399
+ $( #[ $meta] ) *
421
400
impl <$( $T: StableInterpolate ) ,* > StableInterpolate for ( $( $T, ) * ) {
422
401
fn interpolate_stable( & self , other: & Self , t: f32 ) -> Self {
423
402
(
@@ -430,68 +409,12 @@ macro_rules! impl_stable_interpolate_tuple {
430
409
} ;
431
410
}
432
411
433
- // (See `macro_metavar_expr`, which might make this better.)
434
- // This currently implements `StableInterpolate` for tuples of up to 11 elements.
435
- impl_stable_interpolate_tuple ! ( ( T , 0 ) ) ;
436
- impl_stable_interpolate_tuple ! ( ( T0 , 0 ) , ( T1 , 1 ) ) ;
437
- impl_stable_interpolate_tuple ! ( ( T0 , 0 ) , ( T1 , 1 ) , ( T2 , 2 ) ) ;
438
- impl_stable_interpolate_tuple ! ( ( T0 , 0 ) , ( T1 , 1 ) , ( T2 , 2 ) , ( T3 , 3 ) ) ;
439
- impl_stable_interpolate_tuple ! ( ( T0 , 0 ) , ( T1 , 1 ) , ( T2 , 2 ) , ( T3 , 3 ) , ( T4 , 4 ) ) ;
440
- impl_stable_interpolate_tuple ! ( ( T0 , 0 ) , ( T1 , 1 ) , ( T2 , 2 ) , ( T3 , 3 ) , ( T4 , 4 ) , ( T5 , 5 ) ) ;
441
- impl_stable_interpolate_tuple ! (
442
- ( T0 , 0 ) ,
443
- ( T1 , 1 ) ,
444
- ( T2 , 2 ) ,
445
- ( T3 , 3 ) ,
446
- ( T4 , 4 ) ,
447
- ( T5 , 5 ) ,
448
- ( T6 , 6 )
449
- ) ;
450
- impl_stable_interpolate_tuple ! (
451
- ( T0 , 0 ) ,
452
- ( T1 , 1 ) ,
453
- ( T2 , 2 ) ,
454
- ( T3 , 3 ) ,
455
- ( T4 , 4 ) ,
456
- ( T5 , 5 ) ,
457
- ( T6 , 6 ) ,
458
- ( T7 , 7 )
459
- ) ;
460
- impl_stable_interpolate_tuple ! (
461
- ( T0 , 0 ) ,
462
- ( T1 , 1 ) ,
463
- ( T2 , 2 ) ,
464
- ( T3 , 3 ) ,
465
- ( T4 , 4 ) ,
466
- ( T5 , 5 ) ,
467
- ( T6 , 6 ) ,
468
- ( T7 , 7 ) ,
469
- ( T8 , 8 )
470
- ) ;
471
- impl_stable_interpolate_tuple ! (
472
- ( T0 , 0 ) ,
473
- ( T1 , 1 ) ,
474
- ( T2 , 2 ) ,
475
- ( T3 , 3 ) ,
476
- ( T4 , 4 ) ,
477
- ( T5 , 5 ) ,
478
- ( T6 , 6 ) ,
479
- ( T7 , 7 ) ,
480
- ( T8 , 8 ) ,
481
- ( T9 , 9 )
482
- ) ;
483
- impl_stable_interpolate_tuple ! (
484
- ( T0 , 0 ) ,
485
- ( T1 , 1 ) ,
486
- ( T2 , 2 ) ,
487
- ( T3 , 3 ) ,
488
- ( T4 , 4 ) ,
489
- ( T5 , 5 ) ,
490
- ( T6 , 6 ) ,
491
- ( T7 , 7 ) ,
492
- ( T8 , 8 ) ,
493
- ( T9 , 9 ) ,
494
- ( T10 , 10 )
412
+ all_tuples_enumerated ! (
413
+ #[ doc( fake_variadic) ]
414
+ impl_stable_interpolate_tuple,
415
+ 1 ,
416
+ 11 ,
417
+ T
495
418
) ;
496
419
497
420
/// A type that has tangents.
0 commit comments