Skip to content

Use generic names for std RNG's #10053

Closed
Closed

Description

@brson

We've continued to fiddle with our RNG's. It may not be prudent to expose the implementation details of them and instead just call them something like FastRng and CryptoRng, to give us flexibility to change which algorithms are used in the future. On the other hand, an RNG like XorShift in particular has some peculiar properties that are implementation specifc, so it may be harder to replace. Opinions?

Activity

  1. zkamsler commented on Oct 24, 2013

    @zkamsler
    Contributor

    There is some value in knowing the specific algorithm used, particularly if one wants to replay or independently generate specific seeded sequences of random numbers. I have done this from time to time for games.

    Another possibility could be typedefs to more generic names, which would allow replacing the default algorithms for people who don't care about the specific algorithm, but would still make removing specific ones difficult.

  2. capnrefsmmat commented on Oct 24, 2013

    @capnrefsmmat

    An opinion from left field:

    This would prevent users from seeding the RNGs with fixed values and getting a fixed output stream across Rust versions. If I'm writing an automated test of some mathematical routine that uses random numbers, I may seed it so I will get the same results each time; if Rust changes the RNG under me, my tests will break.

    (For example, I may have some algorithm for sampling from a weird probability distribution. I could seed the RNG and compare Rust's output to a known-good algorithm, but then the output would change a few versions later.)

  3. huonw commented on Oct 24, 2013

    @huonw
    Contributor

    We have StdRng and TaskRng types for this purpose. I'm not 100% sure we need to add more aliases.

  4. alexcrichton commented on Jun 5, 2014

    @alexcrichton
    Member

    Closing, I agree with @huonw, the current names are really all we need.

  5. added a commit that references this issue on Dec 17, 2022
  6. added a commit that references this issue on Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions