add SeedableRng::fork methods#17
Merged
newpavlov merged 1 commit intorust-random:masterfrom Nov 6, 2025
Merged
Conversation
newpavlov
approved these changes
Nov 5, 2025
newpavlov
reviewed
Nov 6, 2025
This provide a fork method to "clone" an Rng. This is handy to initialize an Rng that needs to be given to another thread for example.
7e8c133 to
2cd8915
Compare
tarcieri
approved these changes
Nov 6, 2025
Member
|
Is this feature purely for convenience / user experience or also intended to allow implementers to provide their own implementations? |
Contributor
Author
|
Convenience and readability. |
Contributor
|
I think it’s nice to have something to point at as a secure and convenient replacement for |
Contributor
Author
|
I mean, there is nothing in the current API stopping us from using from_rng and duplicate the body (and this is what we did in crypto-primes). But I believe fork is more readable as it carry the intent. |
Member
|
It is an acceptable addition (considering the |
takumi-earth
pushed a commit
to earthlings-dev/rand_core
that referenced
this pull request
Jan 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CHANGELOG.mdentrySummary
This provide a fork method to "clone" an Rng.
Motivation
This is handy to initialize an Rng that needs to be given to another thread for example.
rand_chachaused to provide a clonableChacha20Rng(arguably incorrect).chacha20::Chacha20Rngis not clonable. But it's convenient to fork RNGs when initializing a thread or whatnot.Details