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
79
80
81
82
83
84
85
86
87
#![cfg_attr(not(test), no_std)]

#[macro_use]
mod int_macros;
#[macro_use]
mod uint_macros;
#[macro_use]
mod test_macros;

macro_rules! oint_decl {
    ($SelfT:ident, $ActualT:ident) => {
        #[allow(non_camel_case_types)]
        #[derive(Debug, Copy, Clone)]
        pub struct $SelfT(pub(crate) Option<$ActualT>);
    };
}

oint_decl! {oi8, i8}
oint_decl! {oi16, i16}
oint_decl! {oi32, i32}
oint_decl! {oi64, i64}
oint_decl! {oi128, i128}
oint_decl! {oisize, isize}

oint_decl! {ou8, u8}
oint_decl! {ou16, u16}
oint_decl! {ou32, u32}
oint_decl! {ou64, u64}
oint_decl! {ou128, u128}
oint_decl! {ousize, usize}

oint_impl! {oi8, i8, mod_oi8}
oint_impl! {oi16, i16, mod_oi16}
oint_impl! {oi32, i32, mod_oi32}
oint_impl! {oi64, i64, mod_oi64}
oint_impl! {oi128, i128, mod_oi128}
oint_impl! {oisize, isize, mod_oisize}

ouint_impl! {ou8, u8, mod_ou8}
ouint_impl! {ou16, u16, mod_ou16}
ouint_impl! {ou32, u32, mod_ou32}
ouint_impl! {ou64, u64, mod_ou64}
ouint_impl! {ou128, u128, mod_ou128}
ouint_impl! {ousize, usize, mod_ousize}

#[cfg(test)]
mod total_operations {
    use crate::*;

    oint_test_binop! {test_oi8_add, test_i8_add, +}
    oint_test_binop! {test_oi8_sub, test_i8_sub, -}
    oint_test_binop! {test_oi8_mul, test_i8_mul, *}
    oint_test_binop! {test_oi8_div, test_i8_div, /}
    oint_test_binop! {test_oi8_rem, test_i8_rem, %}
    oint_test_binop! {test_oi8_shl, test_i8_shl, <<}
    oint_test_binop! {test_oi8_shr, test_i8_shr, >>}

    oint_test_binfun! {test_oi8_div_euclid, test_i8_div_eucvlid, div_euclid}
}

#[macro_export]
macro_rules! structural_eq {
    ($lhs:expr, $rhs:expr) => {
        $lhs.structural_eq($rhs)
    };
}

#[macro_export]
macro_rules! structural_ne {
    ($lhs:expr, $rhs:expr) => {
        $lhs.structural_ne($rhs)
    };
}

#[macro_export]
macro_rules! indeterminate_eq {
    ($lhs:expr, $rhs:expr) => {
        $lhs.indeterminate_eq($rhs)
    };
}

#[macro_export]
macro_rules! indeterminate_ne {
    ($lhs:expr, $rhs:expr) => {
        $lhs.indeterminate_ne($rhs)
    };
}