Closed Harnesser closed 4 years ago
Sorry, I don't quite follow. If you know how to improve the documentation though, a contribution would be very welcome!
To answer your bullet points:
SeedableRng::seed_from_u64
is the easiest way to seed from an integerrand_core
(other than utilities for implementing new RNGs) are availble in rand
tooSmallRng
/ StdRng
; you may want to look at the rand_xoshiro
and rand_pcg
crates (first one isn't published yet but hopefully will be later today)It's also worth noting that using gen_range
or the Uniform
distribution may be a little faster and more accurate than using gen()
and modifying/shifting the result. Here's an expanded example.
Thanks - the first example was especially useful!
I would have like to have found a "recipe" page in the docs with:
I'd like to have a go at creating such a page for documentation, as thanks for your help. I'm not sure if the page would be best in the rand book, or in the main Rust Cookbook. What do you think?
Thanks again!
I'm not sure if the page would be best in the rand book, or in the main Rust Cookbook. What do you think?
Depends where people are more likely to look for such documentation?
The book as it stands was written fairly quickly to at least have some doc beyond the API. It could certainly be expanded significantly. I can't gauge what content all readers want and also don't currently want to contribute new content to the book myself, but if you would like to I would be happy to review.
Hi all,
I'd love to see recipe page on the best way to generate seeded random floats for procedural generation applications.
This request comes from a recent unsuccessful experience I had trying to upgrade from 0.3 to 0.6 of
rand
. My 0.3 code uses a {SeedableRng
,from_seed()
,next_f32()
} recipe I found on the web somewhere that's not suitable for 0.6, plus a--seed
command line option to set the seed.from_seed_u64()
now?rand_core
as well as the usualrand
toCargo.toml
.Thanks!