-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from isaacholt100/latest
Latest
- Loading branch information
Showing
27 changed files
with
559 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
- Add optional borsh support | ||
- Add `digits_mut` method to unsigned integers. | ||
- `As` and `CastFrom` traits no longer const, as const trait support removed from latest nightly. | ||
- `cast_signed` method for unsigned integers. | ||
- `cast_unsigned` method for signed integers. | ||
- `midpoint` method for integers. | ||
- `carrying_add` and `borrowing_sub` methods for signed integers. | ||
- strict methods added. | ||
- added `(bnum) ` prefix to error messages that were lacking it. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
macro_rules! bigint_helpers { | ||
($BUint: ident, $BInt: ident, $Digit: ident) => { | ||
#[doc = doc::bigint_helpers::impl_desc!()] | ||
impl<const N: usize> $BInt<N> { | ||
crate::int::bigint_helpers::impls!(I); | ||
} | ||
|
||
#[cfg(test)] | ||
paste::paste! { | ||
mod [<$Digit _digit_tests>] { | ||
use crate::test::types::big_types::$Digit::*; | ||
crate::int::bigint_helpers::tests!(itest); | ||
} | ||
} | ||
}; | ||
} | ||
|
||
use crate::doc; | ||
|
||
crate::macro_impl!(bigint_helpers); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
macro_rules! strict { | ||
($BUint: ident, $BInt: ident, $Digit: ident) => { | ||
#[doc = doc::strict::impl_desc!()] | ||
impl<const N: usize> $BInt<N> { | ||
crate::int::strict::impls!(I); | ||
|
||
#[doc = doc::strict::strict_abs!(I)] | ||
#[must_use = doc::must_use_op!()] | ||
#[inline] | ||
pub const fn strict_abs(self) -> Self { | ||
crate::errors::option_expect!( | ||
self.checked_abs(), | ||
crate::errors::err_msg!("attempt to negate with overflow") | ||
) | ||
} | ||
|
||
#[doc = doc::strict::strict_add_unsigned!(I)] | ||
#[must_use = doc::must_use_op!()] | ||
#[inline] | ||
pub const fn strict_add_unsigned(self, rhs: $BUint<N>) -> Self { | ||
crate::errors::option_expect!( | ||
self.checked_add_unsigned(rhs), | ||
crate::errors::err_msg!("attempt to add with overflow") | ||
) | ||
} | ||
|
||
#[doc = doc::strict::strict_sub_unsigned!(I)] | ||
#[must_use = doc::must_use_op!()] | ||
#[inline] | ||
pub const fn strict_sub_unsigned(self, rhs: $BUint<N>) -> Self { | ||
crate::errors::option_expect!( | ||
self.checked_sub_unsigned(rhs), | ||
crate::errors::err_msg!("attempt to subtract with overflow") | ||
) | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
paste::paste! { | ||
mod [<$Digit _digit_tests>] { | ||
use crate::test::types::big_types::$Digit::*; | ||
crate::int::strict::tests!(itest); | ||
|
||
test_bignum! { | ||
function: <itest>::strict_abs(a: itest), | ||
skip: a.checked_abs().is_none() | ||
} | ||
test_bignum! { | ||
function: <itest>::strict_add_unsigned(a: itest, b: utest), | ||
skip: a.checked_add_unsigned(b).is_none() | ||
} | ||
test_bignum! { | ||
function: <itest>::strict_sub_unsigned(a: itest, b: utest), | ||
skip: a.checked_sub_unsigned(b).is_none() | ||
} | ||
} | ||
} | ||
}; | ||
} | ||
|
||
use crate::doc; | ||
|
||
crate::macro_impl!(strict); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.