-
Notifications
You must be signed in to change notification settings - Fork 432
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
Move Rng
to rand-core crate?
#264
Comments
I’m still waiting on rand-core before upgrading my rdrand crate. |
Thinking about it now, an alternative implementation of the same thing would work for me, one based on the features. Namely, the Although that would still not allow swapping out the implementations for "built-in" Rngs. |
I am in support of using
We can make
I think RNG implementations can still depend on the
Is it about crate-level documentation or item-level documentation? I don't think that amount of duplicated documentation will be that big, also if it will be deemed necessary we can just re-export traits or the whole |
We could, but there's an issue: the extension trait cannot be object-safe (it consists entirely of generic functions). This means users need to use the base trait where they want a type-erased RNG: I don't really see a problem with the documentation, but see this comment. |
I think the implementation of each RNG and the traits are logically independent, so it makes sense to have them in different crates, like rustcrypto does for its algorithms. |
Sounds like this is decided. Closing in favour of PR #288. |
This has come up many times already, so quick summary:
Rng
,SeedableRng
,Error
, and some related code to a new crate,rand-core
Rng
(impls
andle
modules) torand-core
rand
tooDo we want to do this?
Note: this has already been tested.
Also note:
rand
already supportsno_std
; we don't needrand-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:
rand-core
and user docs inrand
OsRng
(see below)rand-core
Against:
PRNG sub-crates: we can for example move
XorShiftRng
to arand-small
crate, which depends on therand-core
, and haverand
exposeXorShiftRng
asWeakRng
. If we tried to do this without a separaterand-core
there 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
OsRng
to a sub-crate, and allow users building a binary on a platform not supported by ourOsRng
to replace ourrand-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 keepthread_rng
etc.The text was updated successfully, but these errors were encountered: