#expand #macro #proc-macro

bin toti

为多个泛型宏扩展 N 次

1 个不稳定版本

0.1.0 2024 年 6 月 15 日

#656过程宏

MIT/Apache

8KB
52

T-Zero, T-One 即 toti

示例

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

扩展为

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) {}

依赖项

~280–740KB
~17K SLoC