rand_mt

GitHub Actions Discord Twitter
Crate API API master

Implemenents a selection of Mersenne Twister random number generators.

A very fast random number generator of period 219937-1. (Makoto Matsumoto, 1997).

The Mersenne Twister algorithms are not suitable for cryptographic uses, but are ubiquitous. See the Mersenne Twister website. A variant of Mersenne Twister is the default PRNG in Ruby.

This crate depends on rand_core.

Usage

Add this to your Cargo.toml:

toml [dependencies] rand_core = "0.5" rand_mt = "3"

Then create a RNG like:

```rust use randcore::RngCore; use randmt::Mt64;

let mut rng = Mt64::newunseeded(); assertne!(rng.nextu64(), rng.nextu64()); ```

Crate Features

rand_mt is no_std compatible. rand_mt has an optional std feature which is enabled by default that adds std::error::Error impls when enabled.

Mersenne Twister requires ~2.5KB of internal state. To make the RNGs implemented in this crate practical to embed in other structs, you may wish to store the RNG in a Box.

License

rand_mt is distributed under the terms of either the MIT License or the Apache License (Version 2.0).

rand_mt is derived from rust-mersenne-twister @ 1.1.1 which is Copyright (c) 2015 rust-mersenne-twister developers.