Skip to content

Commit

Permalink
Avoid to use floating point match
Browse files Browse the repository at this point in the history
Its going to be forbidden, see issue 41255.
  • Loading branch information
est31 committed Apr 14, 2017
1 parent 43ef63d commit baeec7b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/librand/distributions/gamma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}
}

Expand Down

0 comments on commit baeec7b

Please sign in to comment.