Skip to content
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

documentation issues #1225

Closed
dynnamitt opened this issue Apr 7, 2022 · 3 comments · Fixed by rust-random/book#51
Closed

documentation issues #1225

dynnamitt opened this issue Apr 7, 2022 · 3 comments · Fixed by rust-random/book#51

Comments

@dynnamitt
Copy link

dynnamitt commented Apr 7, 2022

Background

rustc 1.59.0

When Learning to use "rand" I tend to end up in a loop of frustration that I must address.
In my quest as a (rust) newbie I tried following the code snippets in your book , I end up with "failed to resolve" at times :

Rand Book

StdGen snippets works fine,
But how do I "use" SmallRng or ChaCha20Rng, usually "failed to resolve" no matter what I try.

I seems my Cargo.toml / dependencies is missing something, or is it the sample snippet missing "use" ?
How many dependencies (with options) do I need for each sample snippet.. could this be more specific perhaps?

@dynnamitt
Copy link
Author

dynnamitt commented Apr 7, 2022

A perfect solution for me at least I think is if someone added:

"this is how your Cargo.toml must look like to run EVERY sample code block inside this book: ..."

@dhardy
Copy link
Member

dhardy commented Apr 7, 2022

So, SmallRng is behind a feature flag, hence you need something like this:

rand = { version = "0.8", features = ["small_rng"] }

ChaCha is in another crate, so you need to depend on that:

rand_chacha = "0.3"

Then, you can e.g.:

use rand_chacha::ChaCha8Rng;

Does this answer your questions? If so, it would be useful to get more specific feedback on how to include this in the book (or even if you make a pull request yourself: https://github.com/rust-random/book/pulls). My perspective is a little different than yours, hence it's not always obvious to me what is missing.

@dynnamitt
Copy link
Author

Thanks!,
I think my comment above is one suggestion , I'm not rusty enough to comfortably pull-request accurate text, instead I have to learn more about feature options in the toml etc :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants