rust-random / book

The Rust Rand Book
Other
49 stars 19 forks source link

"Crates and features" implies that `rand` subsumes `rand_chacha` #39

Open Nemo157 opened 3 years ago

Nemo157 commented 3 years ago

Based on the dependency graph on https://rust-random.github.io/book/crates.html it looks like rand provides access to rand_chacha. While, according to https://docs.rs/rand/0.8.3/rand/rngs/struct.StdRng.html, rand_chacha is actually a private dependency of rand, and if you want access to the chacha family of PRNGs you should depend on rand_chacha yourself, similar to rand_distr. (I assume similar for rand_pcg/rand_hc, and I think rand_pcg actually even isn't a dependency of rand anymore).

dhardy commented 3 years ago

Correct. rand_pcg should be removed. rand_chacha and rand_hc are both optional.

The reason for that graph is to talk about the total dependencies — we had some suggestions that rand had too many a while back.

So what should we do — point out that some of these are private?

Nemo157 commented 3 years ago

Ah, my impression from the initial prose was that the page was more about showing the relationships between the family of crates, not the actual dependency graph. As a private implementation detail I don't see that it's useful for users to know that rand depends on rand_chacha to provide its StdRng, and would have just gone for a graph like

getrandom ┐
          └ rand_core ┐
                      ├ rand ┐
                      │      ├ rand_distr
                      │      └ statrs
                      ├ rand_chacha
                      ├ rand_hc
                      ├ rand_pcg
                      └ rand_xoshiro

(and would extend it to include all the rust-random maintained crates).

dhardy commented 3 years ago

Sounds reasonable. @vks do you agree?

dhardy commented 3 years ago

I think we can go ahead and do this. Like to make a PR @Nemo157 ?

vks commented 3 years ago

I agree it makes sense to omit private dependencies, and to update the graph with the other Rand crates.