pub struct Rng { /* private fields */ }
Expand description
A random number generator.
Implementations§
Source§impl Rng
impl Rng
Sourcepub fn fill_bytes(&mut self, bytes: &mut [u8])
pub fn fill_bytes(&mut self, bytes: &mut [u8])
Fills a slice with random bytes.
Sourcepub fn gen_chance(&mut self, probability: f64) -> bool
pub fn gen_chance(&mut self, probability: f64) -> bool
Returns true
with a given probability.
The probability is the chance from 0.0
(never) to 1.0
(always) that
this function returns true
.
Sourcepub fn gen_range<T: SampleUniform>(&mut self, range: impl SampleRange<T>) -> T
pub fn gen_range<T: SampleUniform>(&mut self, range: impl SampleRange<T>) -> T
Generates a random number within a given range.
Sourcepub fn gen_ratio<T: Number + SampleUniform>(
&mut self,
numerator: T,
denominator: T,
) -> bool
pub fn gen_ratio<T: Number + SampleUniform>( &mut self, numerator: T, denominator: T, ) -> bool
Returns true
with a probability expressed by the ratio between two given
numbers.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Rng
impl RefUnwindSafe for Rng
impl Send for Rng
impl Sync for Rng
impl Unpin for Rng
impl UnwindSafe for Rng
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more