Skip to content

Random number generators should not implement Copy #20170

Closed
@nagisa

Description

@nagisa

Currently there’s a few random number generators that implement Copy:

  • StdRng
  • Isaac*Rng
  • ChaChaRng

All of these random number generators have a bad property of also copying their seed/internal data implicitly, rather than splitting their seed between original and copied generators. This means that Rng in question will start generating the same sequence values when generator is passed by value.

These generators should not implement Copy (implicit) and implement Clone (explicit) instead in case copying generators is intended (which is almost never a case), like XorShiftRng does. Maybe I just missed the use-case of Copyable PRNGs?

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