repr_offset/macros/
for_boolean_const_enums.rs

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
fn main() {
    fn as_ty(b: bool) -> &'static str {
        if b {
            "$t"
        } else {
            "$f"
        }
    }

    for elem_count in 0..=4 {
        for bits in 0..1 << elem_count {
            let is_optional = (0..elem_count)
                .map(|i| (bits >> i) & 1 != 0)
                .collect::<Vec<bool>>();

            let tup = is_optional.iter().copied().map(as_ty).collect::<Vec<_>>();
            let any_optional = is_optional.iter().cloned().any(|x| !x);

            println!(
                "({tup})={output},",
                tup = tup.join(","),
                output = if any_optional { "$f" } else {"Carry" },
            )
        }
    }
}

*/

macro_rules! impl_all_trait_for_tuples {
    (
        macro = $the_macro:ident,
        true = $t:ident,
        false = $f:ident,
    ) => {
        $the_macro! {small=> ()=Carry }
        $the_macro! {small=> ($f,)=$f }
        $the_macro! {small=> ($t,)=Carry }
        $the_macro! {small=> ($f,$f)=$f }
        $the_macro! {small=> ($t,$f)=$f }
        $the_macro! {small=> ($f,$t)=$f }
        $the_macro! {small=> ($t,$t)=Carry }
        $the_macro! {small=> ($f,$f,$f)=$f }
        $the_macro! {small=> ($t,$f,$f)=$f }
        $the_macro! {small=> ($f,$t,$f)=$f }
        $the_macro! {small=> ($t,$t,$f)=$f }
        $the_macro! {small=> ($f,$f,$t)=$f }
        $the_macro! {small=> ($t,$f,$t)=$f }
        $the_macro! {small=> ($f,$t,$t)=$f }
        $the_macro! {small=> ($t,$t,$t)=Carry }
        $the_macro! {small=> ($f,$f,$f,$f)=$f }
        $the_macro! {small=> ($t,$f,$f,$f)=$f }
        $the_macro! {small=> ($f,$t,$f,$f)=$f }
        $the_macro! {small=> ($t,$t,$f,$f)=$f }
        $the_macro! {small=> ($f,$f,$t,$f)=$f }
        $the_macro! {small=> ($t,$f,$t,$f)=$f }
        $the_macro! {small=> ($f,$t,$t,$f)=$f }
        $the_macro! {small=> ($t,$t,$t,$f)=$f }
        $the_macro! {small=> ($f,$f,$f,$t)=$f }
        $the_macro! {small=> ($t,$f,$f,$t)=$f }
        $the_macro! {small=> ($f,$t,$f,$t)=$f }
        $the_macro! {small=> ($t,$t,$f,$t)=$f }
        $the_macro! {small=> ($f,$f,$t,$t)=$f }
        $the_macro! {small=> ($t,$f,$t,$t)=$f }
        $the_macro! {small=> ($f,$t,$t,$t)=$f }
        $the_macro! {small=> ($t,$t,$t,$t)=Carry }

        $the_macro! {large=>(A0,A1,A2,A3,),A4,}
        $the_macro! {large=>(A0,A1,A2,A3,),A4,A5,}
        $the_macro! {large=>(A0,A1,A2,A3,),A4,A5,A6,}
        $the_macro! {large=>(A0,A1,A2,A3,),(A4,A5,A6,A7,),}
        $the_macro! {large=>(A0,A1,A2,A3,),(A4,A5,A6,A7,),A8,}
        $the_macro! {large=>(A0,A1,A2,A3,),(A4,A5,A6,A7,),A8,A9,}
        $the_macro! {large=>(A0,A1,A2,A3,),(A4,A5,A6,A7,),A8,A9,A10,}
        $the_macro! {large=>(A0,A1,A2,A3,),(A4,A5,A6,A7,),(A8,A9,A10,A11,),}
    };
}