repr_offset/macros/
for_boolean_const_enums.rs

1/*
2fn main() {
3    fn as_ty(b: bool) -> &'static str {
4        if b {
5            "$t"
6        } else {
7            "$f"
8        }
9    }
10
11    for elem_count in 0..=4 {
12        for bits in 0..1 << elem_count {
13            let is_optional = (0..elem_count)
14                .map(|i| (bits >> i) & 1 != 0)
15                .collect::<Vec<bool>>();
16
17            let tup = is_optional.iter().copied().map(as_ty).collect::<Vec<_>>();
18            let any_optional = is_optional.iter().cloned().any(|x| !x);
19
20            println!(
21                "({tup})={output},",
22                tup = tup.join(","),
23                output = if any_optional { "$f" } else {"Carry" },
24            )
25        }
26    }
27}
28
29*/
30
31macro_rules! impl_all_trait_for_tuples {
32    (
33        macro = $the_macro:ident,
34        true = $t:ident,
35        false = $f:ident,
36    ) => {
37        $the_macro! {small=> ()=Carry }
38        $the_macro! {small=> ($f,)=$f }
39        $the_macro! {small=> ($t,)=Carry }
40        $the_macro! {small=> ($f,$f)=$f }
41        $the_macro! {small=> ($t,$f)=$f }
42        $the_macro! {small=> ($f,$t)=$f }
43        $the_macro! {small=> ($t,$t)=Carry }
44        $the_macro! {small=> ($f,$f,$f)=$f }
45        $the_macro! {small=> ($t,$f,$f)=$f }
46        $the_macro! {small=> ($f,$t,$f)=$f }
47        $the_macro! {small=> ($t,$t,$f)=$f }
48        $the_macro! {small=> ($f,$f,$t)=$f }
49        $the_macro! {small=> ($t,$f,$t)=$f }
50        $the_macro! {small=> ($f,$t,$t)=$f }
51        $the_macro! {small=> ($t,$t,$t)=Carry }
52        $the_macro! {small=> ($f,$f,$f,$f)=$f }
53        $the_macro! {small=> ($t,$f,$f,$f)=$f }
54        $the_macro! {small=> ($f,$t,$f,$f)=$f }
55        $the_macro! {small=> ($t,$t,$f,$f)=$f }
56        $the_macro! {small=> ($f,$f,$t,$f)=$f }
57        $the_macro! {small=> ($t,$f,$t,$f)=$f }
58        $the_macro! {small=> ($f,$t,$t,$f)=$f }
59        $the_macro! {small=> ($t,$t,$t,$f)=$f }
60        $the_macro! {small=> ($f,$f,$f,$t)=$f }
61        $the_macro! {small=> ($t,$f,$f,$t)=$f }
62        $the_macro! {small=> ($f,$t,$f,$t)=$f }
63        $the_macro! {small=> ($t,$t,$f,$t)=$f }
64        $the_macro! {small=> ($f,$f,$t,$t)=$f }
65        $the_macro! {small=> ($t,$f,$t,$t)=$f }
66        $the_macro! {small=> ($f,$t,$t,$t)=$f }
67        $the_macro! {small=> ($t,$t,$t,$t)=Carry }
68
69        $the_macro! {large=>(A0,A1,A2,A3,),A4,}
70        $the_macro! {large=>(A0,A1,A2,A3,),A4,A5,}
71        $the_macro! {large=>(A0,A1,A2,A3,),A4,A5,A6,}
72        $the_macro! {large=>(A0,A1,A2,A3,),(A4,A5,A6,A7,),}
73        $the_macro! {large=>(A0,A1,A2,A3,),(A4,A5,A6,A7,),A8,}
74        $the_macro! {large=>(A0,A1,A2,A3,),(A4,A5,A6,A7,),A8,A9,}
75        $the_macro! {large=>(A0,A1,A2,A3,),(A4,A5,A6,A7,),A8,A9,A10,}
76        $the_macro! {large=>(A0,A1,A2,A3,),(A4,A5,A6,A7,),(A8,A9,A10,A11,),}
77    };
78}