/rust/registry/src/index.crates.io-1949cf8c6b5b557f/fastnum-0.3.2/src/bint/checked.rs
Line | Count | Source |
1 | | macro_rules! checked_impl { |
2 | | ($Ty: ident, $sign: ident) => { |
3 | | #[doc = doc::checked::impl_desc!()] |
4 | | impl<const N: usize> $Ty<N> { |
5 | | #[doc = doc::checked::checked_add!($sign 256)] |
6 | | #[must_use = doc::must_use_op!()] |
7 | | #[inline(always)] |
8 | 0 | pub const fn checked_add(self, rhs: Self) -> Option<Self> { |
9 | 0 | tuple_to_option(self.overflowing_add(rhs)) |
10 | 0 | } Unexecuted instantiation: <fastnum::bint::int::Int<_>>::checked_add Unexecuted instantiation: <fastnum::bint::uint::UInt<_>>::checked_add |
11 | | |
12 | | #[doc = doc::checked::checked_sub!($sign 256)] |
13 | | #[must_use = doc::must_use_op!()] |
14 | | #[inline(always)] |
15 | 0 | pub const fn checked_sub(self, rhs: Self) -> Option<Self> { |
16 | 0 | tuple_to_option(self.overflowing_sub(rhs)) |
17 | 0 | } Unexecuted instantiation: <fastnum::bint::int::Int<_>>::checked_sub Unexecuted instantiation: <fastnum::bint::uint::UInt<_>>::checked_sub |
18 | | |
19 | | #[doc = doc::checked::checked_mul!($sign 256)] |
20 | | #[must_use = doc::must_use_op!()] |
21 | | #[inline(always)] |
22 | 0 | pub const fn checked_mul(self, rhs: Self) -> Option<Self> { |
23 | 0 | tuple_to_option(self.overflowing_mul(rhs)) |
24 | 0 | } Unexecuted instantiation: <fastnum::bint::int::Int<_>>::checked_mul Unexecuted instantiation: <fastnum::bint::uint::UInt<_>>::checked_mul |
25 | | |
26 | | #[doc = doc::checked::checked_div!($sign 256)] |
27 | | #[must_use = doc::must_use_op!()] |
28 | | #[inline(always)] |
29 | 0 | pub const fn checked_div(self, rhs: Self) -> Option<Self> { |
30 | 0 | tuple_to_option(self.overflowing_div(rhs)) |
31 | 0 | } Unexecuted instantiation: <fastnum::bint::int::Int<_>>::checked_div Unexecuted instantiation: <fastnum::bint::uint::UInt<_>>::checked_div |
32 | | |
33 | | #[doc = doc::checked::checked_div_euclid!($sign 256)] |
34 | | #[must_use = doc::must_use_op!()] |
35 | | #[inline(always)] |
36 | 0 | pub const fn checked_div_euclid(self, rhs: Self) -> Option<Self> { |
37 | 0 | tuple_to_option(self.overflowing_div_euclid(rhs)) |
38 | 0 | } Unexecuted instantiation: <fastnum::bint::int::Int<_>>::checked_div_euclid Unexecuted instantiation: <fastnum::bint::uint::UInt<_>>::checked_div_euclid |
39 | | |
40 | | #[doc = doc::checked::checked_rem!($sign 256)] |
41 | | #[must_use = doc::must_use_op!()] |
42 | | #[inline(always)] |
43 | 0 | pub const fn checked_rem(self, rhs: Self) -> Option<Self> { |
44 | 0 | tuple_to_option(self.overflowing_rem(rhs)) |
45 | 0 | } Unexecuted instantiation: <fastnum::bint::int::Int<_>>::checked_rem Unexecuted instantiation: <fastnum::bint::uint::UInt<_>>::checked_rem |
46 | | |
47 | | #[doc = doc::checked::checked_rem_euclid!($sign 256)] |
48 | | #[must_use = doc::must_use_op!()] |
49 | | #[inline(always)] |
50 | 0 | pub const fn checked_rem_euclid(self, rhs: Self) -> Option<Self> { |
51 | 0 | tuple_to_option(self.overflowing_rem_euclid(rhs)) |
52 | 0 | } Unexecuted instantiation: <fastnum::bint::int::Int<_>>::checked_rem_euclid Unexecuted instantiation: <fastnum::bint::uint::UInt<_>>::checked_rem_euclid |
53 | | |
54 | | #[doc = doc::checked::checked_shl!($sign 256)] |
55 | | #[must_use = doc::must_use_op!()] |
56 | | #[inline(always)] |
57 | 0 | pub const fn checked_shl(self, rhs: ExpType) -> Option<Self> { |
58 | 0 | tuple_to_option(self.overflowing_shl(rhs)) |
59 | 0 | } Unexecuted instantiation: <fastnum::bint::int::Int<_>>::checked_shl Unexecuted instantiation: <fastnum::bint::uint::UInt<_>>::checked_shl |
60 | | |
61 | | #[doc = doc::checked::checked_shr!($sign 256)] |
62 | | #[must_use = doc::must_use_op!()] |
63 | | #[inline(always)] |
64 | 0 | pub const fn checked_shr(self, rhs: ExpType) -> Option<Self> { |
65 | 0 | tuple_to_option(self.overflowing_shr(rhs)) |
66 | 0 | } Unexecuted instantiation: <fastnum::bint::int::Int<_>>::checked_shr Unexecuted instantiation: <fastnum::bint::uint::UInt<_>>::checked_shr |
67 | | |
68 | | #[doc = doc::checked::checked_pow!($sign 256)] |
69 | | #[must_use = doc::must_use_op!()] |
70 | | #[inline(always)] |
71 | 0 | pub const fn checked_pow(self, pow: ExpType) -> Option<Self> { |
72 | 0 | tuple_to_option(self.overflowing_pow(pow)) |
73 | 0 | } Unexecuted instantiation: <fastnum::bint::int::Int<_>>::checked_pow Unexecuted instantiation: <fastnum::bint::uint::UInt<_>>::checked_pow |
74 | | |
75 | | #[doc = doc::checked::checked_next_multiple_of!($sign 256)] |
76 | | #[must_use = doc::must_use_op!()] |
77 | | #[inline(always)] |
78 | 0 | pub const fn checked_next_multiple_of(self, rhs: Self) -> Option<Self> { |
79 | 0 | match self.0.checked_next_multiple_of(rhs.0) { |
80 | 0 | Some(value) => Some(Self(value)), |
81 | 0 | None => None, |
82 | | } |
83 | 0 | } Unexecuted instantiation: <fastnum::bint::int::Int<_>>::checked_next_multiple_of Unexecuted instantiation: <fastnum::bint::uint::UInt<_>>::checked_next_multiple_of |
84 | | |
85 | | #[doc = doc::checked::checked_neg!($sign 256)] |
86 | | #[must_use = doc::must_use_op!()] |
87 | | #[inline(always)] |
88 | 0 | pub const fn checked_neg(self) -> Option<Self> { |
89 | 0 | tuple_to_option(self.overflowing_neg()) |
90 | 0 | } Unexecuted instantiation: <fastnum::bint::int::Int<_>>::checked_neg Unexecuted instantiation: <fastnum::bint::uint::UInt<_>>::checked_neg |
91 | | } |
92 | | }; |
93 | | } |
94 | | |
95 | | pub(crate) use checked_impl; |