#expand #macro #proc-macro

macro bin toti

Expand macro N times for multiple generics

1 unstable release

0.1.0 Jun 15, 2024

#675 in Procedural macros

MIT/Apache

8KB
52 lines

T-Zero, T-One aka toti

Example

#[toti::expand(10)]
macro_rules! impls {
  ($($T:ident),+) => {
    impl<$($T),+> Trait for ($($T,)+) {}
  };
}

Expands into

impl<T0> Trait for (T0,) {}
impl<T0, T1> Trait for (T0, T1) {}
impl<T0, T1, T2> Trait for (T0, T1, T2) {}
impl<T0, T1, T2, T3> Trait for (T0, T1, T2, T3) {}
impl<T0, T1, T2, T3, T4> Trait for (T0, T1, T2, T3, T4) {}
impl<T0, T1, T2, T3, T4, T5> Trait for (T0, T1, T2, T3, T4, T5) {}
impl<T0, T1, T2, T3, T4, T5, T6> Trait for (T0, T1, T2, T3, T4, T5, T6) {}
impl<T0, T1, T2, T3, T4, T5, T6, T7> Trait for (T0, T1, T2, T3, T4, T5, T6, T7) {}
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8> Trait for (T0, T1, T2, T3, T4, T5, T6, T7, T8) {}
impl<T0, T1, T2, T3, T4, T5, T6, T7, T8, T9> Trait for (T0, T1, T2, T3, T4, T5, T6, T7, T8, T9) {}

Dependencies

~250–710KB
~17K SLoC