Skip to content

Commit baeec7b

Browse files
committed
Avoid to use floating point match
Its going to be forbidden, see issue 41255.
1 parent 43ef63d commit baeec7b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

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)