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

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

Open
dhardy opened this issue Feb 9, 2024 · 0 comments
Open

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

dhardy opened this issue Feb 9, 2024 · 0 comments
Labels
E-question Participation: opinions wanted

Comments

@dhardy
Copy link
Member

dhardy commented Feb 9, 2024

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 dhardy added the E-question Participation: opinions wanted label Feb 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-question Participation: opinions wanted
Projects
None yet
Development

No branches or pull requests

1 participant