pub struct Random {
pub rng: SmallRng,
}Expand description
Random represents a PRNG.
It is a reimplementation of quickcheck::Gen, which does not export the
methods we need to properly generate random values.
It is unspecified whether this is a secure RNG or not. Therefore, callers should assume it is insecure.
Fields§
§rng: SmallRngImplementations§
Source§impl Random
impl Random
pub fn arbitrary<T: Arbitrary>(&self) -> T
pub fn from_seed(seed: u64) -> Self
Sourcepub fn choose<'a, T>(&mut self, slice: &'a [T]) -> Option<&'a T>
pub fn choose<'a, T>(&mut self, slice: &'a [T]) -> Option<&'a T>
Choose among the possible alternatives in the slice given. If the slice
is empty, then None is returned. Otherwise, a non-None value is
guaranteed to be returned.
pub fn gen<T>(&mut self) -> Twhere
Standard: Distribution<T>,
pub fn gen_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
Auto Trait Implementations§
impl Freeze for Random
impl RefUnwindSafe for Random
impl Send for Random
impl Sync for Random
impl Unpin for Random
impl UnsafeUnpin for Random
impl UnwindSafe for Random
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