rust-random / rand

A Rust library for random number generation.
https://crates.io/crates/rand
Other
1.67k stars 432 forks source link

Rng renames: gen_ → random_ #1505

Closed dhardy closed 1 month ago

dhardy commented 1 month ago

Summary

This appears to be the conclusion of #1503:

rng.random()
rng.random_iter()
rng.random_range(..len)
rng.random_bool(0.2)
rng.random_ratio(2, 3)
rng.sample(Open01)
rng.sample_iter(Open01)
rng.fill(&mut buf)

Opinion

My personal feeling is that this is a poor choice. We recently renamed rand::distributions to rand::distr because the latter was easier to type and consistent with rand_distr (see #1381). This achieves some level of consistency (excepting that random_bool describes its output while other random* methods describe their input), but is not concise.

vks commented 1 month ago

I don't really like the new name. I would prefer something like sample_* or uniform_*, but I guess this is too technical.

I agree that random_ratio is misleading, but so is gen_ratio. I think bool_from_ratio or bool_from_prob would also work.