Crate features
For definitive documentation of crate features, check the crate release's Cargo.toml
:
- https://docs.rs/crate/rand/latest/source/Cargo.toml.orig
- https://docs.rs/crate/rand_core/latest/source/Cargo.toml.orig
- https://docs.rs/crate/rand_distr/latest/source/Cargo.toml.orig
Common features
The following features are common to rand_core
, rand
, rand_distr
and potentially some RNG crates:
std
: opt into functionality dependent on thestd
lib. This is default-enabled except inrand_core
; forno_std
usage, usedefault-features = false
.alloc
: enables functionality requiring an allocator (for usage withno_std
). This is implied bystd
.serde1
: enables serialization via [serde
], version 1.0.
Rand features
Additional rand
features:
small_rng
enables theSmallRng
generator (feature-gated since v0.7).simd_support
: Experimental support for generating various SIMD types (requires nightlyrustc
).log
enables a few log messages via [log
].
Note regarding SIMD: the above flag concerns explicit generation of SIMD types only and not optimisation. SIMD operations may be used internally regardless of this flag; e.g. the ChaCha generator has explicit support for SIMD operations internally.
rand_distr features
The floating point functions from num_traits
and libm
are used to support
no_std
environments and ensure reproducibility. If the floating point
functions from std
are preferred, which may provide better accuracy and
performance but may produce different random values, the std_math
feature
can be enabled. (Note that any other crate depending on num-traits
's std
feature (default-enabled) will have the same effect.)