Skip to content

Commit 6c6bfc9

Browse files
committed
Explicitly allow integer overflow in test
Overflow here is safe and preserves the invariant, and I now need to be explicit to avoid a panic. In release mode, there was never a panic, but the code didn’t express that overflow is safe.
1 parent 0cb9339 commit 6c6bfc9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/calculate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ mod test_get_leaves {
211211
Some(r) => r,
212212
None => return TestResult::discard(),
213213
};
214-
let z = 4 * get_leaves(&x) - y;
214+
let z = get_leaves(&x).wrapping_mul(4).wrapping_sub(y);
215215
TestResult::from_bool(*x.ex() == z)
216216
}
217217
}

0 commit comments

Comments
 (0)