1use crate::{BInt, BUint};
4
5macro_rules! int_type_doc {
6 ($bits: literal, $sign: literal) => {
7 concat!($bits, "-bit ", $sign, " integer type.")
8 };
9}
10
11macro_rules! int_types {
12 { $($bits: literal $u: ident $i: ident; ) *} => {
13 $(
14 #[doc = int_type_doc!($bits, "unsigned")]
15 pub type $u = BUint::<{$bits / 64}>;
16
17 #[doc = int_type_doc!($bits, "signed")]
18 pub type $i = BInt::<{$bits / 64}>;
19 )*
20 };
21}
22
23macro_rules! call_types_macro {
24 ($name: ident) => {
25 $name! {
26 128 U128 I128;
27 256 U256 I256;
28 512 U512 I512;
29 1024 U1024 I1024;
30 2048 U2048 I2048;
31 4096 U4096 I4096;
32 8192 U8192 I8192;
33 }
34 };
35}
36
37call_types_macro!(int_types);
38
39#[cfg(test)]
40mod tests {
41 use super::*;
42
43 macro_rules! assert_int_bits {
44 { $($bits: literal $u: ident $i: ident; ) *} => {
45 $(
46 assert_eq!($u::BITS, $bits);
47 assert_eq!($i::BITS, $bits);
48 )*
49 }
50 }
51
52 #[test]
53 fn test_int_bits() {
54 call_types_macro!(assert_int_bits);
55 }
56}