Skip to content

Commit 91f5370

Browse files
authored
Reorder asserts for easier debugging.
When the caller erroneously passes NaN's, it is much easier to diagnose with the asserts in this order. With finite arguments, the error message is unchanged.
1 parent 6ecbe26 commit 91f5370

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/distributions/uniform.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -827,11 +827,15 @@ macro_rules! uniform_float_impl {
827827
{
828828
let low = *low_b.borrow();
829829
let high = *high_b.borrow();
830-
assert!(low.all_lt(high), "Uniform::new called with `low >= high`");
831830
assert!(
832-
low.all_finite() && high.all_finite(),
833-
"Uniform::new called with non-finite boundaries"
831+
low.all_finite()
832+
"Uniform::new called with `low` non-finite."
834833
);
834+
assert!(
835+
high.all_finite()
836+
"Uniform::new called with `high` non-finite."
837+
);
838+
assert!(low.all_lt(high), "Uniform::new called with `low >= high`");
835839
let max_rand = <$ty>::splat(
836840
(::core::$u_scalar::MAX >> $bits_to_discard).into_float_with_exponent(0) - 1.0,
837841
);

0 commit comments

Comments
 (0)