Skip to content

Commit 9dea259

Browse files
committed
Merge rust-bitcoin#4710: Update NumOpResult arbitrary impl to only consume 1 byte of entropy
453888a Update NumOpResult arbitrary impl to only consume 1 byte of entropy (Shing Him Ng) Pull request description: Took some inspiration from [a comment](rust-bitcoin#4689 (comment)) in rust-bitcoin#4689 and looked through the rest of the codebase to update `u.int_in_range(0..=1)` to use `bool::arbitrary(u)` ACKs for top commit: yancyribbens: cr ACK 453888a tcharding: ACK 453888a apoelstra: ACK 453888a; successfully ran local tests Tree-SHA512: 2ee44d4bd06749be4a44b18a64e36f49a5e2b9ac9fb186b54615d8979b8bbb6b62e4a86255355bd15ed1b030eb415a3902a269b842b20c5bcf48a479ad62381c
2 parents 660a306 + 453888a commit 9dea259

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

units/src/result.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,10 +325,9 @@ impl fmt::Display for MathOp {
325325
#[cfg(feature = "arbitrary")]
326326
impl<'a, T: Arbitrary<'a>> Arbitrary<'a> for NumOpResult<T> {
327327
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
328-
let choice = u.int_in_range(0..=1)?;
329-
match choice {
330-
0 => Ok(NumOpResult::Valid(T::arbitrary(u)?)),
331-
_ => Ok(NumOpResult::Error(NumOpError(MathOp::arbitrary(u)?))),
328+
match bool::arbitrary(u)? {
329+
true => Ok(NumOpResult::Valid(T::arbitrary(u)?)),
330+
false => Ok(NumOpResult::Error(NumOpError(MathOp::arbitrary(u)?))),
332331
}
333332
}
334333
}

0 commit comments

Comments
 (0)