Closed dhardy closed 5 days ago
So in benchmarks we're now doing stuff like this:
bench(&mut g, "chacha20", ChaCha20Rng::from_os_rng());
bench(&mut g, "std", StdRng::from_os_rng());
bench(&mut g, "small", SmallRng::from_rand_rng());
The reason we don't have from_rand_rng
everywhere is because SeedableRng
is defined in rand_core
and rand::rng
is not available there.
This leads me to conclude that perhaps:
SmallRng::from_rand_rng
which is a special case, and use RNG::from_rng(&mut rand::rng())
insteadrand_core
back into rand
so that we can add SeedableRng::from_rand_rng
. Major caveat: rand
will not be able to depend on externally-defined-RNGs like StdRng
currently does.Obviously, the first solution looks better. from_thread_rng
was added in #1368 where the SeedableRng
impl was dropped, but that has since been added back in.
CHANGELOG.md
entrySummary
Title
Motivation
Function
thread_rng
was renamed to justrng
. We can't call this methodfrom_rng
since that clashes with theSeedableRng
method, so this seems like the next best choice (also aligning somewhat with the terminology we use in docs).