Module rug::rand[][src]

Random number generation.

This module provides two main structs.

  1. RandState is thread safe and can be shared and sent across threads.
  2. 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

RandState

The state of a random number generator.

ThreadRandState

The state of a random number generator that is suitable for a single thread only.

Traits

MutRandState

Used to pass the state of random number generators by mutable reference.

RandGen

Custom random number generator to be used with RandState.

ThreadRandGen

Custom random number generator to be used with ThreadRandState.