Expand description
Random number generation.
This module provides two main structs.
RandState
is thread safe and can be shared and sent across threads.ThreadRandState
is suitable for use in a single thread.
RandState
has constructors for Mersenne Twister and for linear congruential
random number generators. It can also be constructed using a custom random
number generator implementing the RandGen
trait, which has to implement
Send
and Sync
too.
If you need a custom random number generator that cannot be shared or sent
across threads, you can use ThreadRandState
instead. ThreadRandState
can
be constructed using a custom random number generator implementing the
ThreadRandGen
trait, which does not have to implement Send
or
Sync
.
Both RandState
and ThreadRandState
implement the MutRandState
trait
so that they can be used with methods like
Integer::random_below
.
Structs§
- The state of a random number generator.
- The state of a random number generator that is suitable for a single thread only.
Traits§
- Used to pass the state of random number generators by mutable reference.
- Custom random number generator to be used with
RandState
. - Custom random number generator to be used with
ThreadRandState
.