Add Arbitrary to SignedAmount type

This commit is contained in:
yancy 2024-08-29 20:11:55 -05:00
parent d7ac6af5b4
commit 3f244db19d
1 changed files with 8 additions and 0 deletions

View File

@ -1594,6 +1594,14 @@ impl core::iter::Sum for SignedAmount {
}
}
#[cfg(feature = "arbitrary")]
impl<'a> Arbitrary<'a> for SignedAmount {
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
let s = i64::arbitrary(u)?;
Ok(SignedAmount(s))
}
}
/// Calculates the sum over the iterator using checked arithmetic.
pub trait CheckedSum<R>: private::SumSeal<R> {
/// Calculates the sum over the iterator using checked arithmetic. If an over or underflow would