Skip to main content

bnum/buint/
strict.rs

1macro_rules! strict {
2    ($BUint: ident, $BInt: ident, $Digit: ident) => {
3        #[doc = doc::strict::impl_desc!()]
4        impl<const N: usize> $BUint<N> {
5            crate::int::strict::impls!(U);
6
7            #[doc = doc::strict::strict_add_signed!(U)]
8            #[must_use = doc::must_use_op!()]
9            #[inline]
10            pub const fn strict_add_signed(self, rhs: $BInt<N>) -> Self {
11                crate::errors::option_expect!(
12                    self.checked_add_signed(rhs),
13                    crate::errors::err_msg!("attempt to add with overflow")
14                )
15            }
16        }
17    };
18}
19
20#[cfg(test)]
21crate::test::all_digit_tests! {
22    crate::int::strict::tests!(utest);
23
24    test_bignum! {
25        function: <utest>::strict_add_signed(a: utest, b: itest),
26        skip: a.checked_add_signed(b).is_none()
27    }
28}
29
30use crate::doc;
31
32crate::macro_impl!(strict);