Skip to content

Random package

The Random package provides support generating random numbers. The package provides random number generators you can use in your code, a dice roller and a trait for implementing your own random number generator.

If your application does not require a specific generator, use Rand.

Seed values can contain up to 128 bits of randomness in the form of two U64s. A common non-cryptographically secure way to seed a generator is with Time.now.

let rand = Rand
let n = rand.next()

Public Types