rust-random / rand

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

Rename rand::distributions to rand::distr ? #1381

Closed dhardy closed 4 months ago

dhardy commented 9 months ago

Summary

Rename the module rand::distributions to rand::distr.

Add an alias re-exporting the module through rand::distributions to avoid unnecessary breakage.

pub mod distr;
#[doc(no_inline)] pub use distr as distributions;

Motivation

  1. distr is easier to type than distributions
  2. Consistency with rand_distr
  3. Consistency with the Rust standard library which abbreviates most long module names (cmp, env, alloc, mem, but exceptionally collections)

Note: we do not abbreviate to dist partly because rand_distr already established a convention but mostly "distr" is relatively unambiguous whereas "dist" has other likely meanings.

Making distr the official module name encourages usage; adding distributions as an alias limits breakage for the many existing users.

Alternative: no alias

The plan above is to never remove the alias: there is no support for deprecating aliases. This may cause users some confusion when reading code, especially if we choose to hide the alias in docs.

As an alternative, we could rename without an alias. Most users should only need to fix a few imports or can easily search-and-replace rand::distributions, besides which the next release will have some breakage (notably, distribution constructors now return a Result).

dhardy commented 6 months ago

(This was mentioned in #1297.)

dhardy commented 4 months ago

Done: #1470.