Skip to content

Commit

Permalink
Add trait ReproducibleRng
Browse files Browse the repository at this point in the history
  • Loading branch information
dhardy committed Jan 29, 2025
1 parent 9bc595d commit 5ec1757
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions rand_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,7 @@ impl<R: TryCryptoRng> CryptoRng for UnwrapErr<R> {}
/// This trait encapsulates the low-level functionality common to all
/// pseudo-random number generators (PRNGs, or algorithmic generators).
///
/// Note that this trait does not imply
/// [reproducibility](https://rust-random.github.io/book/crate-reprod.html)
/// of results; this is an optional property which RNGs should mention in their
/// documentation.
///
/// [`rand`]: https://docs.rs/rand
/// This trait does not imply reproducibility; see [`ReproducibleRng`].
pub trait SeedableRng: Sized {
/// Seed type, which is restricted to types mutably-dereferenceable as `u8`
/// arrays (we recommend `[u8; N]` for some `N`).
Expand Down Expand Up @@ -520,6 +515,13 @@ pub trait SeedableRng: Sized {
}
}

/// A reproducible random number generator
///
/// This is a marker trait indicating that the implementation commits to
/// [reproducibility](https://rust-random.github.io/book/crate-reprod.html)
/// of results across platforms and at least patch versions.
pub trait ReproducibleRng: SeedableRng {}

/// Adapter that enables reading through a [`io::Read`](std::io::Read) from a [`RngCore`].
///
/// # Examples
Expand Down

0 comments on commit 5ec1757

Please sign in to comment.