The Principal Dev – Masterclass for Tech Leads

The Principal Dev – Masterclass for Tech LeadsJuly 17-18

Join

Rand

Test Status Crate Book API API

Rand is a set of crates supporting (pseudo-)random generators:

With broad support for random value generation and random processes:

All with:

Rand is not:

Documentation:

Versions

Rand is mature (suitable for general usage, with infrequent breaking releases which minimise breakage) but not yet at 1.0. Current MAJOR.MINOR versions are:

See the CHANGELOG or Upgrade Guide for more details.

Crate Features

Rand is built with these features enabled by default:

Optionally, the following dependencies can be enabled:

Additionally, these features configure Rand:

Note that nightly features are not stable and therefore not all library and compiler versions will be compatible. This is especially true of Rand's experimental simd_support feature.

Rand supports limited functionality in no_std mode (enabled via default-features = false). In this case, OsRng and from_os_rng are unavailable (unless os_rng is enabled), large parts of seq are unavailable (unless alloc is enabled), and ThreadRng is unavailable.

Portability and platform support

Many (but not all) algorithms are intended to have reproducible output. Read more in the book: Portability.

The Rand library supports a variety of CPU architectures. Platform integration is outsourced to getrandom.

WebAssembly support

The WASI and Emscripten targets are directly supported. The wasm32-unknown-unknown target is not automatically supported. To enable support for this target, refer to the getrandom documentation for WebAssembly. Alternatively, the os_rng feature may be disabled.

License

Rand is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE and LICENSE-MIT, and COPYRIGHT for details.

Join libs.tech

...and unlock some superpowers

GitHub

We won't share your data with anyone else.