diff options
| author | Simonas Kazlauskas <git@kazlauskas.me> | 2015-01-04 14:58:08 +0200 |
|---|---|---|
| committer | Simonas Kazlauskas <git@kazlauskas.me> | 2015-01-04 14:58:08 +0200 |
| commit | e723fe07783cd9b797c9f1456d359879bba44907 (patch) | |
| tree | fb9c6542c71a236a14d291dca46a53a23d9b76cb | |
| parent | 7e3d1157246a13a7830431ce0253368029c8ee3e (diff) | |
Do not use entropy during gen_weighted_bool(1)
1 in 1 chance to return true always results in true.
| -rw-r--r-- | src/librand/lib.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/librand/lib.rs b/src/librand/lib.rs index 0f8dbc78cde..18f508e816f 100644 --- a/src/librand/lib.rs +++ b/src/librand/lib.rs @@ -243,7 +243,7 @@ pub trait Rng : Sized { /// println!("{}", rng.gen_weighted_bool(3)); /// ``` fn gen_weighted_bool(&mut self, n: uint) -> bool { - n == 0 || self.gen_range(0, n) == 0 + n <= 1 || self.gen_range(0, n) == 0 } /// Return an iterator of random characters from the set A-Z,a-z,0-9. |
