1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
pub trait Gate {
type Target;
fn pass(self) -> Self::Target;
}
macro_rules! gate {
($($from:ident),*) => {
impl<$($from: Gate),*> Gate for ($($from,)*) {
type Target = ($($from::Target,)*);
#[allow(non_snake_case)]
fn pass(self) -> Self::Target {
let ($($from,)*) = self;
($($from.pass(),)*)
}
}
}
}
gate!();
gate!(A);
gate!(A, B);
gate!(A, B, C);
gate!(A, B, C, D);
gate!(A, B, C, D, E);
gate!(A, B, C, D, E, F);
gate!(A, B, C, D, E, F, G);
gate!(A, B, C, D, E, F, G, H);