Skip to content

SeedableRng to include from_seed_const #1612

@phughk

Description

@phughk

Background

I am making a single-allocation game (no heap, no alloc) in a nostd environment.
The allocation is fairly big for embedded devices (currently at 18kb).
Since this is a moderately large allocation, I would like it to be allocated outside the stack (not necessarily heap).
To achieve this, I have a const constructor.
The RNG needs to be included in the constructor (I am using Lcg64Xsh32).

What is your motivation?

I would like to initialise the rng internally of a const constructor.

What type of application is this? (E.g. cryptography, game, numerical simulation)

Embedded systems game with c-type interface.
Targets GameBoy Advance, Wasm, Desktop, maybe others.
Also targets machine learning models that can read from the entire allocation and learn to play.

Feature request

Add a const variant constructor for SeedableRng please

impl SeedableRng for ... {
    type Seed = [u8; 16];

    fn from_seed(seed: Self::Seed) -> Self {
        ...
    }

    const fn from_seed_const(seed: Self::Seed) -> Self {
        ...
    }
}

Happy to work on this if the feature request is agreed to be helpful

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