reweb3_num/bint/
wrapping.rs1use crate::{doc, ExpType};
2
3macro_rules! wrapping {
4 ($BUint: ident, $BInt: ident, $Digit: ident) => {
5 #[doc = doc::wrapping::impl_desc!()]
6 impl<const N: usize> $BInt<N> {
7 #[doc = doc::wrapping::wrapping_add!(I)]
8 #[must_use = doc::must_use_op!()]
9 #[inline]
10 pub const fn wrapping_add(self, rhs: Self) -> Self {
11 Self::from_bits(self.bits.wrapping_add(rhs.bits))
12 }
13
14 #[doc = doc::wrapping::wrapping_add_unsigned!(I)]
15 #[must_use = doc::must_use_op!()]
16 #[inline]
17 pub const fn wrapping_add_unsigned(self, rhs: $BUint<N>) -> Self {
18 self.overflowing_add_unsigned(rhs).0
19 }
20
21 #[doc = doc::wrapping::wrapping_sub!(I)]
22 #[must_use = doc::must_use_op!()]
23 #[inline]
24 pub const fn wrapping_sub(self, rhs: Self) -> Self {
25 Self::from_bits(self.bits.wrapping_sub(rhs.bits))
26 }
27
28 #[doc = doc::wrapping::wrapping_sub_unsigned!(I)]
29 #[must_use = doc::must_use_op!()]
30 #[inline]
31 pub const fn wrapping_sub_unsigned(self, rhs: $BUint<N>) -> Self {
32 self.overflowing_sub_unsigned(rhs).0
33 }
34
35 #[doc = doc::wrapping::wrapping_mul!(I)]
36 #[must_use = doc::must_use_op!()]
37 #[inline]
38 pub const fn wrapping_mul(self, rhs: Self) -> Self {
39 Self::from_bits(self.bits.wrapping_mul(rhs.bits))
40 }
41
42 #[doc = doc::wrapping::wrapping_div!(I)]
43 #[must_use = doc::must_use_op!()]
44 #[inline]
45 pub const fn wrapping_div(self, rhs: Self) -> Self {
46 self.overflowing_div(rhs).0
47 }
48
49 #[doc = doc::wrapping::wrapping_div_euclid!(I)]
50 #[must_use = doc::must_use_op!()]
51 #[inline]
52 pub const fn wrapping_div_euclid(self, rhs: Self) -> Self {
53 self.overflowing_div_euclid(rhs).0
54 }
55
56 #[doc = doc::wrapping::wrapping_rem!(I)]
57 #[must_use = doc::must_use_op!()]
58 #[inline]
59 pub const fn wrapping_rem(self, rhs: Self) -> Self {
60 self.overflowing_rem(rhs).0
61 }
62
63 #[doc = doc::wrapping::wrapping_rem_euclid!(I)]
64 #[must_use = doc::must_use_op!()]
65 #[inline]
66 pub const fn wrapping_rem_euclid(self, rhs: Self) -> Self {
67 self.overflowing_rem_euclid(rhs).0
68 }
69
70 #[doc = doc::wrapping::wrapping_neg!(I)]
71 #[must_use = doc::must_use_op!()]
72 #[inline]
73 pub const fn wrapping_neg(self) -> Self {
74 self.overflowing_neg().0
75 }
76
77 #[doc = doc::wrapping::wrapping_shl!(I)]
78 #[must_use = doc::must_use_op!()]
79 #[inline]
80 pub const fn wrapping_shl(self, rhs: ExpType) -> Self {
81 self.overflowing_shl(rhs).0
82 }
83
84 #[doc = doc::wrapping::wrapping_shr!(I)]
85 #[must_use = doc::must_use_op!()]
86 #[inline]
87 pub const fn wrapping_shr(self, rhs: ExpType) -> Self {
88 self.overflowing_shr(rhs).0
89 }
90
91 #[doc = doc::wrapping::wrapping_abs!(I)]
92 #[must_use = doc::must_use_op!()]
93 #[inline]
94 pub const fn wrapping_abs(self) -> Self {
95 self.overflowing_abs().0
96 }
97
98 #[doc = doc::wrapping::wrapping_pow!(I)]
99 #[must_use = doc::must_use_op!()]
100 #[inline]
101 pub const fn wrapping_pow(self, pow: ExpType) -> Self {
102 Self::from_bits(self.bits.wrapping_pow(pow))
104 }
105 }
106 };
107}
108
109crate::macro_impl!(wrapping);