-
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
Reorganisation of Rand items #435
Conversation
src/lib.rs
Outdated
@@ -804,8 +810,8 @@ pub trait FromEntropy: SeedableRng { | |||
/// errors, use the following code, equivalent aside from error handling: | |||
/// | |||
/// ```rust | |||
/// # use rand::Error; | |||
/// use rand::{Rng, StdRng, EntropyRng, SeedableRng}; | |||
/// use rand::{Error, prelude::*}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should keep the old # use ...
/// [`SmallRng`]: rngs/struct.SmallRng.html | ||
#[deprecated(since="0.5.0", note="removed in favor of SmallRng")] | ||
#[cfg(feature="std")] | ||
pub fn weak_rng() -> XorShiftRng { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Diff is messed up; this didn't change (only random
pasted below and 2 Rngs removed)
I will have a good look tomorrow. |
Two things stand out to me as really nice: the prelude (and what is included in it) and separating out But for the rest I think #430 looks much cleaner, sorry... But we are having trouble coming closer in how we look at things. In a way it matters little how it all is organised. The most important outcome is presenting something easy and logical to users in documentation and imports. Having less modules to traverse seems like a win to me then, unless things are really not related. I don't really like the name I still see no problem moving
Wasn't the argument that it is used in the public API of |
You are right about the mis-use of the word "entropy"; we already have
So, what to do? I kind of like the Question, if you are okay with an Okay, fine, I guess we can put most stuff together, like |
Notes on further mis-uses of "entropy". One description of "entropy" is as a measure of disorder, which can imply external disorder. I don't think we're too far wrong with our usage
|
These are almost exclusively for implementation of certain types of RNG, therefore exposing BlockRngCore in rand is not useful.
Updated and fixed (again). @pitdicker happy? The 'adaptor' module isn't the best name; trying to strike a middle ground and I guess it's okay ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pitdicker happy?
Completely 😄
What can I say but 🎉 |
This is an alternative to #430. Only the last two commits make any changes to documentation (other than adding a single line in new modules), so more documentation work is required.
Notably now:
StdRng
,SmallRng
andThreadRng
are only available from therngs
moduleEntropyRng
andOsRng
are only available from theentropy
moduleJitterRng
still has its own module (withinentropy
) but this doesn't seem like a big dealReseedingRng
is only available inreseeding
; it's not going to be used directly much so lets hide itrand_core::block
moduleBlockRngCore
is no longer exported from randAdding the
prelude
is an extra feature; it's not necessary but is nice in some ways. It doesn't contain much from thedistributions
module and omitsError
because including generic names in the prelude might cause problems.I also considered moving
Error
andErrorKind
into theerror
module (from the POV of doc and exports, both in rand and rand_core), which is neater but probably more inconvenient.