Skip to content

Commit e723fe0

Browse files
committed
Do not use entropy during gen_weighted_bool(1)
1 in 1 chance to return true always results in true.
1 parent 7e3d115 commit e723fe0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/librand/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ pub trait Rng : Sized {
243243
/// println!("{}", rng.gen_weighted_bool(3));
244244
/// ```
245245
fn gen_weighted_bool(&mut self, n: uint) -> bool {
246-
n == 0 || self.gen_range(0, n) == 0
246+
n <= 1 || self.gen_range(0, n) == 0
247247
}
248248

249249
/// Return an iterator of random characters from the set A-Z,a-z,0-9.

0 commit comments

Comments
 (0)