1macro_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 pub const fn strict_abs(self) -> Self {
11 crate::errors::option_expect!(
12 self.checked_abs(),
13 crate::errors::err_msg!("attempt to negate with overflow")
14 )
15 }
16
17 #[doc = doc::strict::strict_add_unsigned!(I)]
18 #[must_use = doc::must_use_op!()]
19 #[inline]
20 pub const fn strict_add_unsigned(self, rhs: $BUint<N>) -> Self {
21 crate::errors::option_expect!(
22 self.checked_add_unsigned(rhs),
23 crate::errors::err_msg!("attempt to add with overflow")
24 )
25 }
26
27 #[doc = doc::strict::strict_sub_unsigned!(I)]
28 #[must_use = doc::must_use_op!()]
29 #[inline]
30 pub const fn strict_sub_unsigned(self, rhs: $BUint<N>) -> Self {
31 crate::errors::option_expect!(
32 self.checked_sub_unsigned(rhs),
33 crate::errors::err_msg!("attempt to subtract with overflow")
34 )
35 }
36 }
37 };
38}
39
40#[cfg(test)]
41crate::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
58use crate::doc;
59
60crate::macro_impl!(strict);