Skip to content

Seedable RNG and separation/extension of .gen_* functions #2379

Closed
@Dretch

Description

@Dretch

There should be some sort of seedable implementation of rand::rng so that sequences of random operations can be easily reproduced.

The gen_* methods in the rand::rng iface should be separated out into an iface-less implementation for the rand::rng iface-type, i.e.:

impl gen for rng {
    fn gen_str (len: uint) -> str { ... }
    ....
}

This will allow multiple implementations of the rand::rng iface to use the gen_* methods.

There should be more gen_* methods available, for example:

  • there should be one for each primitive integer/float type
  • there should be shuffle-vector, choose-from-vector, choose-from-weighted-vector methods
  • the functions from /src/fuzzer/rand_util.rs should become gen_methods

Motivation

I have been writing a fuzzer and I would have found these things useful to have in the core/std library.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsC-enhancementCategory: An issue proposing an enhancement or a PR with one.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions