You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Also note: randalready supports no_std; we don't need rand-core for that!
I think it's time we tried to answer this question. I already know some people would like to see this, but I'm less clear of all the reasons. I know @burdges doesn't, because it divides related logic between two different crates, and is mostly unnecessary.
For:
fairly clean separation; we can put backend docs in rand-core and user docs in rand
enables us to move PRNG implementations into sub-crates, and use code from there (see below)
enables some other crate tricks, e.g. allowing users to replace OsRng (see below)
less code to review for crates only needing rand-core
this might restrict specialisation implementations — no currently known issues
code and documentation gets split between two crates (though this is also a potential advantage)
PRNG sub-crates: we can for example move XorShiftRng to a rand-small crate, which depends on the rand-core, and have rand expose XorShiftRng as WeakRng. If we tried to do this without a separate rand-core there would be a cyclic dependency rand → rand-small → rand, so we might have to copy the PRNG code.
User-replaceable OsRng: @pitdicker mentioned this somewhere: move OsRng to a sub-crate, and allow users building a binary on a platform not supported by our OsRng to replace our rand-os crate with their own implementation. It is not practical for us to provide an OS entropy source in all cases, e.g. WASM and embedded platforms, and this would allow users to keep thread_rng etc.
This has come up many times already, so quick summary:
Rng,SeedableRng,Error, and some related code to a new crate,rand-coreRng(implsandlemodules) torand-corerandtooDo we want to do this?
Note: this has already been tested.
Also note:
randalready supportsno_std; we don't needrand-corefor that!I think it's time we tried to answer this question. I already know some people would like to see this, but I'm less clear of all the reasons. I know @burdges doesn't, because it divides related logic between two different crates, and is mostly unnecessary.
For:
rand-coreand user docs inrandOsRng(see below)rand-coreAgainst:
PRNG sub-crates: we can for example move
XorShiftRngto arand-smallcrate, which depends on therand-core, and haverandexposeXorShiftRngasWeakRng. If we tried to do this without a separaterand-corethere would be a cyclic dependencyrand→rand-small→rand, so we might have to copy the PRNG code.User-replaceable OsRng: @pitdicker mentioned this somewhere: move
OsRngto a sub-crate, and allow users building a binary on a platform not supported by ourOsRngto replace ourrand-oscrate with their own implementation. It is not practical for us to provide an OS entropy source in all cases, e.g. WASM and embedded platforms, and this would allow users to keepthread_rngetc.