Skip to content

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

@dhardy

Description

@dhardy

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-questionParticipation: opinions wanted

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions