Skip to content

Commit

Permalink
Merge branch 'latest' of https://github.com/isaacholt100/bnum into la…
Browse files Browse the repository at this point in the history
…test
  • Loading branch information
isaacholt100 committed Feb 16, 2025
2 parents fa15651 + c46e41f commit b4be0c4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/bint/numtraits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ use num_traits::{
Saturating, SaturatingAdd, SaturatingMul, SaturatingSub, Signed, ToPrimitive, WrappingAdd,
WrappingMul, WrappingNeg, WrappingShl, WrappingShr, WrappingSub, Zero, //ConstZero
};
use num_traits::ops::overflowing::{OverflowingAdd, OverflowingSub};

use crate::cast::CastFrom;
use crate::int::numtraits::num_trait_impl;
Expand Down
2 changes: 2 additions & 0 deletions src/buint/numtraits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ use num_traits::{
Saturating, SaturatingAdd, SaturatingMul, SaturatingSub, ToPrimitive, Unsigned, WrappingAdd,
WrappingMul, WrappingNeg, WrappingShl, WrappingShr, WrappingSub, Zero, //ConstZero
};
use num_traits::ops::overflowing::{OverflowingAdd, OverflowingSub};


use crate::cast::CastFrom;
use crate::int::numtraits::num_trait_impl;
Expand Down
9 changes: 9 additions & 0 deletions src/int/numtraits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ macro_rules! impls {
num_trait_impl!($Int, WrappingMul, wrapping_mul, Self);
num_trait_impl!($Int, WrappingSub, wrapping_sub, Self);

num_trait_impl!($Int, OverflowingAdd, overflowing_add, (Self, bool));
num_trait_impl!($Int, OverflowingSub, overflowing_sub, (Self, bool));

impl<const N: usize> CheckedNeg for $Int<N> {
#[inline]
fn checked_neg(&self) -> Option<Self> {
Expand Down Expand Up @@ -427,9 +430,15 @@ macro_rules! tests {
test_bignum! {
function: <$int as WrappingAdd>::wrapping_add(a: ref &$int, b: ref &$int)
}
test_bignum! {
function: <$int as OverflowingAdd>::overflowing_add(a: ref &$int, b: ref &$int)
}
test_bignum! {
function: <$int as WrappingSub>::wrapping_sub(a: ref &$int, b: ref &$int)
}
test_bignum! {
function: <$int as OverflowingSub>::overflowing_sub(a: ref &$int, b: ref &$int)
}
test_bignum! {
function: <$int as WrappingMul>::wrapping_mul(a: ref &$int, b: ref &$int)
}
Expand Down

0 comments on commit b4be0c4

Please sign in to comment.