Skip to content

Commit c04ae0f

Browse files
authored
Rollup merge of #41292 - est31:master, r=BurntSushi
Avoid to use floating point match Its going to be forbidden, see issue #41255.
2 parents adc2b10 + baeec7b commit c04ae0f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

Diff for: src/librand/distributions/gamma.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,14 @@ impl Gamma {
103103
assert!(shape > 0.0, "Gamma::new called with shape <= 0");
104104
assert!(scale > 0.0, "Gamma::new called with scale <= 0");
105105

106-
let repr = match shape {
107-
1.0 => One(Exp::new(1.0 / scale)),
108-
0.0...1.0 => Small(GammaSmallShape::new_raw(shape, scale)),
109-
_ => Large(GammaLargeShape::new_raw(shape, scale)),
106+
let repr = if shape == 1.0 {
107+
One(Exp::new(1.0 / scale))
108+
} else if 0.0 <= shape && shape < 1.0 {
109+
Small(GammaSmallShape::new_raw(shape, scale))
110+
} else {
111+
Large(GammaLargeShape::new_raw(shape, scale))
110112
};
111-
Gamma { repr: repr }
113+
Gamma { repr }
112114
}
113115
}
114116

0 commit comments

Comments
 (0)