Skip to content

Commit 453888a

Browse files
committed
Update NumOpResult arbitrary impl to only consume 1 byte of entropy
1 parent a8e6ab7 commit 453888a

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)