Skip to content

Add trait ReproducibleRng #1570

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion rand_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +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).
///
/// [`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 @@ -515,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