/rust/registry/src/index.crates.io-1949cf8c6b5b557f/bnum-0.12.1/src/bint/strict.rs
Line | Count | Source |
1 | | macro_rules! strict { |
2 | | ($BUint: ident, $BInt: ident, $Digit: ident) => { |
3 | | #[doc = doc::strict::impl_desc!()] |
4 | | impl<const N: usize> $BInt<N> { |
5 | | crate::int::strict::impls!(I); |
6 | | |
7 | | #[doc = doc::strict::strict_abs!(I)] |
8 | | #[must_use = doc::must_use_op!()] |
9 | | #[inline] |
10 | 0 | pub const fn strict_abs(self) -> Self { |
11 | 0 | crate::errors::option_expect!( |
12 | 0 | self.checked_abs(), |
13 | 0 | crate::errors::err_msg!("attempt to negate with overflow") |
14 | | ) |
15 | 0 | } Unexecuted instantiation: <bnum::bint::BInt<_>>::strict_abs Unexecuted instantiation: <bnum::bint::BIntD16<_>>::strict_abs Unexecuted instantiation: <bnum::bint::BIntD8<_>>::strict_abs Unexecuted instantiation: <bnum::bint::BIntD32<_>>::strict_abs |
16 | | |
17 | | #[doc = doc::strict::strict_add_unsigned!(I)] |
18 | | #[must_use = doc::must_use_op!()] |
19 | | #[inline] |
20 | 0 | pub const fn strict_add_unsigned(self, rhs: $BUint<N>) -> Self { |
21 | 0 | crate::errors::option_expect!( |
22 | 0 | self.checked_add_unsigned(rhs), |
23 | 0 | crate::errors::err_msg!("attempt to add with overflow") |
24 | | ) |
25 | 0 | } Unexecuted instantiation: <bnum::bint::BInt<_>>::strict_add_unsigned Unexecuted instantiation: <bnum::bint::BIntD16<_>>::strict_add_unsigned Unexecuted instantiation: <bnum::bint::BIntD8<_>>::strict_add_unsigned Unexecuted instantiation: <bnum::bint::BIntD32<_>>::strict_add_unsigned |
26 | | |
27 | | #[doc = doc::strict::strict_sub_unsigned!(I)] |
28 | | #[must_use = doc::must_use_op!()] |
29 | | #[inline] |
30 | 0 | pub const fn strict_sub_unsigned(self, rhs: $BUint<N>) -> Self { |
31 | 0 | crate::errors::option_expect!( |
32 | 0 | self.checked_sub_unsigned(rhs), |
33 | 0 | crate::errors::err_msg!("attempt to subtract with overflow") |
34 | | ) |
35 | 0 | } Unexecuted instantiation: <bnum::bint::BInt<_>>::strict_sub_unsigned Unexecuted instantiation: <bnum::bint::BIntD16<_>>::strict_sub_unsigned Unexecuted instantiation: <bnum::bint::BIntD8<_>>::strict_sub_unsigned Unexecuted instantiation: <bnum::bint::BIntD32<_>>::strict_sub_unsigned |
36 | | } |
37 | | }; |
38 | | } |
39 | | |
40 | | #[cfg(test)] |
41 | | crate::test::all_digit_tests! { |
42 | | crate::int::strict::tests!(itest); |
43 | | |
44 | | test_bignum! { |
45 | | function: <itest>::strict_abs(a: itest), |
46 | | skip: a.checked_abs().is_none() |
47 | | } |
48 | | test_bignum! { |
49 | | function: <itest>::strict_add_unsigned(a: itest, b: utest), |
50 | | skip: a.checked_add_unsigned(b).is_none() |
51 | | } |
52 | | test_bignum! { |
53 | | function: <itest>::strict_sub_unsigned(a: itest, b: utest), |
54 | | skip: a.checked_sub_unsigned(b).is_none() |
55 | | } |
56 | | } |
57 | | |
58 | | use crate::doc; |
59 | | |
60 | | crate::macro_impl!(strict); |