Skip to content

Commit 25c1c49

Browse files
committed
RngCore: explain what a pathological RNG will break
Cf. rust-random/rngs#25 (comment).
1 parent 9918cc1 commit 25c1c49

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

rand_core/src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,17 @@ pub mod le;
7676
/// [`next_u32`] or [`next_u64`] since the latter methods are almost always used
7777
/// with algorithmic generators (PRNGs), which are normally infallible.
7878
///
79+
/// Implementers should produce bits uniformly. Pathological RNGs (e.g. always
80+
/// returning the same value, or never setting certain bits) can break rejection
81+
/// sampling used by random distributions, and also break other RNGs when
82+
/// seeding them via [`SeedableRng::from_rng`].
83+
///
7984
/// Algorithmic generators implementing [`SeedableRng`] should normally have
8085
/// *portable, reproducible* output, i.e. fix Endianness when converting values
8186
/// to avoid platform differences, and avoid making any changes which affect
8287
/// output (except by communicating that the release has breaking changes).
8388
///
84-
/// Typically implementators will implement only one of the methods available
89+
/// Typically an RNG will implement only one of the methods available
8590
/// in this trait directly, then use the helper functions from the
8691
/// [`impls`] module to implement the other methods.
8792
///

0 commit comments

Comments
 (0)