Merge rust-bitcoin/rust-bitcoin#3274: Add Arbitrary to SignedAmount type
3f244db19d
Add Arbitrary to SignedAmount type (yancy) Pull request description: While proptesting, I've found Arbitrary for SingedAmount to be useful. Would appreciate adding this as well. ACKs for top commit: tcharding: ACK3f244db19d
Kixunil: ACK3f244db19d
Tree-SHA512: f293215505db85998135c75e147f4cb0031a08c7db619b706e6c7d632c6f23783af56992531396aecc6e3da55b107a7f2c7ec4d68a3e5737ebcf4225f306ed29
This commit is contained in:
commit
c2e3e86106
|
@ -1593,6 +1593,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.
|
/// Calculates the sum over the iterator using checked arithmetic.
|
||||||
pub trait CheckedSum<R>: private::SumSeal<R> {
|
pub trait CheckedSum<R>: private::SumSeal<R> {
|
||||||
/// Calculates the sum over the iterator using checked arithmetic. If an over or underflow would
|
/// Calculates the sum over the iterator using checked arithmetic. If an over or underflow would
|
||||||
|
|
Loading…
Reference in New Issue