pub fn random_bool(p: f64) -> bool
Available on crate feature
thread_rng
only.Expand description
Return a bool with a probability p
of being true.
This function is shorthand for
rng().random_bool(p)
.
§Example
println!("{}", rand::random_bool(1.0 / 3.0));
§Panics
If p < 0
or p > 1
.