aboutsummaryrefslogtreecommitdiff
path: root/rng.ha
diff options
context:
space:
mode:
authorJulian Hurst <ark@mansus.space>2024-09-17 10:44:22 +0200
committerJulian Hurst <ark@mansus.space>2024-09-17 10:44:22 +0200
commit3cb80d144f6210a72866057562489c7605a0817e (patch)
tree24073ed853ae67ed086d35c0ad959fe8e4c18e5a /rng.ha
parent1c5c6457eda1b7e9b6fc5ffee1d7f6539b2a04cb (diff)
downloadrng-3cb80d144f6210a72866057562489c7605a0817e.tar.gz
Add protection when unable to generate with given params
Diffstat (limited to 'rng.ha')
-rw-r--r--rng.ha4
1 files changed, 4 insertions, 0 deletions
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 = [];