-
-
Notifications
You must be signed in to change notification settings - Fork 470
Description
One of the major rand
critiques, which I've recently seen, argues that it makes hard to write "quick and dirty" code. This motivates creation of crates like fastrand
, which could lead to an unfortunate ecosystem split and overall code duplication.
We already have the random
helper function and I think it could be worth to add other helper functions as well. To make docs less cluttered we probably should keep them in a separate top-level module (something like helpers
?). With the potential migration to ChaCha8/12, those functions can be simple wrappers around thread_rng
and be fast enough for all, but most demanding use-cases. One of side-effects of using helpers is that trait imports are no longer needed for simple use-cases, so it could be seen as a work-around until something like rust-lang/rfcs#2375 gets added to the language.
A preliminary list of helper functions:
random
(Rng::gen
)gen_range
(ideally should be consistent withgen_range
, see gen_range doesn't take a Range #744)fill
gen_bool
/gen_ratio
choose
/choose_mut
shuffle
We could tweak naming a bit to make it a bit more natural.
cc @stjepang