Macro_rules! for generating const-generic parameters
You could start from here:
macro_rules! comb {
( $( $($a:literal,)* $b:ty $(,$c:ty)* );+ ) => { comb!( $( $($a,)* false $(,$c)* );+ ;
$( $($a,)* true $(,$c)* );+ ); };
( $( $($a:literal),+ );+ ) => { [$( Self::route_beam_impl::<$($a),+>(), )+] };
}
const FN: [RouteFn; 8] = comb!(bool, bool, bool);
The `bool` type can be replaced by any other type; it's just there to differentiate the literal `true` or `false` from what hasn't been replaced yet.
It will expand to:
const FN: [RouteFn; 8] = [Self::route_beam_impl::<false, false, false>(), Self::route_beam_impl::<true, false, false>(), Self::route_beam_impl::<false, true, false>(), Self::route_beam_impl::<true, true, false>(), Self::route_beam_impl::<false, false, true>(), Self::route_beam_impl::<true, false, true>(), Self::route_beam_impl::<false, true, true>(), Self::route_beam_impl::<true, true, true>(), ];
You can replace by something else by changing the last pattern in the macro, but it must produce a valid output in the context it's used, which is why I had to use the turbofish syntax.
The macro replaces a list of comma-separated mix or `bool` and `true`/`false`, those lists being separated by semicolons. When there are only `true`/`false` remaining, it goes to the 2nd pattern to create the array.
It's a little tricky, to be honest, and that won't make your code very easy to read.
PS: There's a limit to how much you can recurse into a macro, but the default limit is 128, so you should be safe.