github.com/rust-random/rand ↗
A Rust library for random number generation.
Open this visualization on its own page →
Contributors
224
Lines of Code
5,505
From
2010-07-26
To
2020-12-18
About rust-random/rand
Rand is a comprehensive Rust library ecosystem for pseudo-random number generation, built around a standard RNG trait. It provides implementations of both cryptographically secure generators and lightweight options optimized for speed and small size, with additional specialized RNG crates available for ChaCha20, xoshiro, PCG, and other algorithms. The library includes automatic seeding capabilities and direct integration with the getrandom crate for system entropy.
Beyond raw number generation, Rand offers extensive functionality for sampling random values from various distributions—including uniform, standard, and non-uniform distributions through companion crates like rand_distr and statrs. It also provides utilities for random processes such as shuffling and sampling sequences. The library emphasizes performance through numerous optimizations, portability with reproducible output across platforms, and partial no_std compatibility for embedded environments.
The project is mature and production-ready but intentionally prioritizes correctness, speed, and flexibility over simplicity, making it more feature-complete but more complex than minimal alternatives. It explicitly does not aim to be a small codebase or primarily a cryptographic library, though it does provide some generators suitable for unpredictable value generation under specific constraints. Rand is distributed under dual MIT and Apache 2.0 licenses.