Skip to content

How to use StepRng with choose? #628

@JeanMertz

Description

@JeanMertz

I'm confused how I can use StepRng with choose().

I validated that my StepRng is working as expected using the same code as the example:

let sample: [u64; 3] = rng.gen();
assert_eq!(sample, [2, 3, 4]);

While the returned integers do increase by 1, as expected, I was under the impression that it would also result in a predictable, but non-constant outcome of choose(), as long as I set the increment value of the RNG to anything other than 0.

However, it looks like I'm always getting the first element of my slice back. This isn't terrible, but it would be nice if this wasn't the case, so I could rule out some situation where the RNG isn't actually used, and the business logic is wired to always return the first value of a slice, which would be undesired behaviour.

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