about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2017-04-13 22:01:28 -0400
committerGitHub <noreply@github.com>2017-04-13 22:01:28 -0400
commitc04ae0f0cfcdc01180afa447585016d52e2667a9 (patch)
treeed7f957c40617780eb7606fc90319da67485918d
parentadc2b10399635b1529d002b4bad21037dff31290 (diff)
parentbaeec7b8eb3ee0fd7a40bff409400903e5679ff5 (diff)
downloadrust-c04ae0f0cfcdc01180afa447585016d52e2667a9.tar.gz
rust-c04ae0f0cfcdc01180afa447585016d52e2667a9.zip
Rollup merge of #41292 - est31:master, r=BurntSushi
Avoid to use floating point match

Its going to be forbidden, see issue #41255.
-rw-r--r--src/librand/distributions/gamma.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/librand/distributions/gamma.rs b/src/librand/distributions/gamma.rs
index e024b62adfb..9a42b82beff 100644
--- a/src/librand/distributions/gamma.rs
+++ b/src/librand/distributions/gamma.rs
@@ -103,12 +103,14 @@ impl Gamma {
         assert!(shape > 0.0, "Gamma::new called with shape <= 0");
         assert!(scale > 0.0, "Gamma::new called with scale <= 0");
 
-        let repr = match shape {
-            1.0 => One(Exp::new(1.0 / scale)),
-            0.0...1.0 => Small(GammaSmallShape::new_raw(shape, scale)),
-            _ => Large(GammaLargeShape::new_raw(shape, scale)),
+        let repr = if shape == 1.0 {
+            One(Exp::new(1.0 / scale))
+        } else if 0.0 <= shape && shape < 1.0 {
+            Small(GammaSmallShape::new_raw(shape, scale))
+        } else {
+            Large(GammaLargeShape::new_raw(shape, scale))
         };
-        Gamma { repr: repr }
+        Gamma { repr }
     }
 }