Reorganisation of Rand items#435
Conversation
| /// ```rust | ||
| /// # use rand::Error; | ||
| /// use rand::{Rng, StdRng, EntropyRng, SeedableRng}; | ||
| /// use rand::{Error, prelude::*}; |
There was a problem hiding this comment.
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.
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 ( |
pitdicker
left a comment
There was a problem hiding this comment.
@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,SmallRngandThreadRngare only available from therngsmoduleEntropyRngandOsRngare only available from theentropymoduleJitterRngstill has its own module (withinentropy) but this doesn't seem like a big dealReseedingRngis only available inreseeding; it's not going to be used directly much so lets hide itrand_core::blockmoduleBlockRngCoreis no longer exported from randAdding the
preludeis an extra feature; it's not necessary but is nice in some ways. It doesn't contain much from thedistributionsmodule and omitsErrorbecause including generic names in the prelude might cause problems.I also considered moving
ErrorandErrorKindinto theerrormodule (from the POV of doc and exports, both in rand and rand_core), which is neater but probably more inconvenient.