From 3cb80d144f6210a72866057562489c7605a0817e Mon Sep 17 00:00:00 2001 From: Julian Hurst Date: Tue, 17 Sep 2024 10:44:22 +0200 Subject: Add protection when unable to generate with given params --- rng.ha | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rng.ha b/rng.ha index d016e15..4ed160a 100644 --- a/rng.ha +++ b/rng.ha @@ -34,6 +34,10 @@ export fn main() void = { }; }; + if (nodups && max < nb) { + fmt::fatal("Can't generate the desired number of randoms without duplicates"); + }; + let seed = time::unix(time::now(time::clock::MONOTONIC)); let r = random::init(seed: u32); let rngs: []u32 = []; -- cgit v1.2.3