Skip to content

Add SmallThreadRng #1781

@adityashah1212

Description

@adityashah1212

Background

What is your motivation?
Same use case as ThreadRng serves today, but something that is faster than ThreadRng while sacrificing crystallographic security.

What type of application is this? (E.g. cryptography, game, numerical simulation)
Simple stuff like a randomized log sampler. Using rand::small_random() is much easier than

thread_local! {
    static RNG: RefCell<SmallRng> = RefCell::new(SmallRng::from_rng(&mut rand::rng()));
}

fn should_emit() -> {
   RNG.with_borrow_mut(|rng| rng.random_ratio(1, 1000)
}

Feature request

Create a type called SmallThreadRng that internally uses same rng as SmallRng.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions