pub trait Rand: Sized {
Show 18 methods
// Required methods
fn from_seed(seed: u64) -> Self;
fn rand_u32(&mut self) -> u32;
// Provided methods
fn rand_u8(&mut self) -> u8 { ... }
fn rand_u16(&mut self) -> u16 { ... }
fn rand_u64(&mut self) -> u64 { ... }
fn rand_usize(&mut self) -> usize { ... }
fn rand_bounded_u32(&mut self, m: u32) -> u32 { ... }
fn rand_bounded_u64(&mut self, m: u64) -> u64 { ... }
fn rand_bounded_usize(&mut self, m: usize) -> usize { ... }
fn rand_range_u32(&mut self, a: u32, b: u32) -> u32 { ... }
fn rand_range_u64(&mut self, a: u64, b: u64) -> u64 { ... }
fn rand_range_i32(&mut self, a: i32, b: i32) -> i32 { ... }
fn rand_range_i64(&mut self, a: i64, b: i64) -> i64 { ... }
fn rand_f32(&mut self) -> f32 { ... }
fn rand_f64(&mut self) -> f64 { ... }
fn choice<'a, T>(&mut self, a: &'a [T]) -> &'a T { ... }
fn shuffle<T>(&mut self, a: &mut [T]) { ... }
fn fill(&mut self, a: &mut [u8]) { ... }
}
Expand description
Provided utilities.
This interface permits to hide the used engine:
fn rng_from_seed(seed: u64) -> impl Rand {
Rng::from_seed(seed)
}
Required Methods§
Provided Methods§
Sourcefn rand_usize(&mut self) -> usize
fn rand_usize(&mut self) -> usize
A sample from the uniform distribution on 0..=usize::MAX
.
Sourcefn rand_bounded_u32(&mut self, m: u32) -> u32
fn rand_bounded_u32(&mut self, m: u32) -> u32
A sample from the uniform distribution on 0..m
.
Sourcefn rand_bounded_u64(&mut self, m: u64) -> u64
fn rand_bounded_u64(&mut self, m: u64) -> u64
A sample from the uniform distribution on 0..m
.
Sourcefn rand_bounded_usize(&mut self, m: usize) -> usize
fn rand_bounded_usize(&mut self, m: usize) -> usize
A sample from the uniform distribution on 0..m
.
Sourcefn rand_range_u32(&mut self, a: u32, b: u32) -> u32
fn rand_range_u32(&mut self, a: u32, b: u32) -> u32
A sample from the uniform distribution on a..b
.
Sourcefn rand_range_u64(&mut self, a: u64, b: u64) -> u64
fn rand_range_u64(&mut self, a: u64, b: u64) -> u64
A sample from the uniform distribution on a..b
.
Sourcefn rand_range_i32(&mut self, a: i32, b: i32) -> i32
fn rand_range_i32(&mut self, a: i32, b: i32) -> i32
A sample from the uniform distribution on a..b
.
Sourcefn rand_range_i64(&mut self, a: i64, b: i64) -> i64
fn rand_range_i64(&mut self, a: i64, b: i64) -> i64
A sample from the uniform distribution on a..b
.
Sourcefn rand_f32(&mut self) -> f32
fn rand_f32(&mut self) -> f32
A sample from the uniform distribution on the interval [0, 1).
⚠️ WARNING: Achieving uniform distribution of floats is complex and
requires analysis yet to be accomplished.
Sourcefn rand_f64(&mut self) -> f64
fn rand_f64(&mut self) -> f64
A sample from the uniform distribution on the interval [0, 1).
⚠️ WARNING: Achieving uniform distribution of floats is complex and
requires analysis yet to be accomplished.
Sourcefn choice<'a, T>(&mut self, a: &'a [T]) -> &'a T
fn choice<'a, T>(&mut self, a: &'a [T]) -> &'a T
A sample from the uniform distribution on the non-empty slice.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.