crypto_bigint/uint/
macros.rs1macro_rules! impl_uint_aliases {
5 ($(($name:ident, $bits:expr, $doc:expr)),+) => {
6 $(
7 #[doc = $doc]
8 #[doc="unsigned big integer."]
9 pub type $name = Uint<{ nlimbs($bits) }>;
10
11 impl $crate::traits::EncodedSize for [u8; { nlimbs($bits) * Limb::BYTES }] {
12 type Target = EncodedUint<{ nlimbs($bits) }>;
13 }
14
15 impl $crate::traits::EncodedSize for EncodedUint<{ nlimbs($bits) }> {
16 type Target = [u8; { nlimbs($bits) * Limb::BYTES }];
17 }
18 )+
19 };
20}
21
22macro_rules! impl_uint_concat_split_mixed {
23 ($name:ident, $size:literal) => {
24 impl $crate::traits::Concat<{ U64::LIMBS * $size }> for Uint<{ <$name>::LIMBS - U64::LIMBS * $size }>
25 {
26 type Output = $name;
27 }
28
29 impl $crate::traits::Split<{ U64::LIMBS * $size }> for $name
30 {
31 type Output = Uint<{ <$name>::LIMBS - U64::LIMBS * $size }>;
32 }
33
34 };
35 ($name:ident, [ $($size:literal),+ ]) => {
36 $(
37 impl_uint_concat_split_mixed!($name, $size);
38 )+
39 };
40 ($( ($name:ident, $sizes:tt), )+) => {
41 $(
42 impl_uint_concat_split_mixed!($name, $sizes);
43 )+
44 };
45}
46
47macro_rules! impl_uint_concat_split_even {
48 ($name:ident) => {
49 #[allow(clippy::integer_division_remainder_used, reason = "constant")]
50 impl $crate::traits::Concat<{ <$name>::LIMBS / 2 }> for Uint<{ <$name>::LIMBS / 2 }>
51 {
52 type Output = $name;
53 }
54
55 #[allow(clippy::integer_division_remainder_used, reason = "constant")]
56 impl $crate::traits::Split<{ <$name>::LIMBS / 2 }> for $name
57 {
58 type Output = Uint<{ <$name>::LIMBS / 2 }>;
59 }
60
61 #[allow(clippy::integer_division_remainder_used, reason = "constant")]
62 impl $crate::traits::SplitEven for $name
63 {
64 type Output = Uint<{ <$name>::LIMBS / 2 }>;
65 }
66 };
67 ($($name:ident,)+) => {
68 $(
69 impl_uint_concat_split_even!($name);
70 )+
71 }
72}