This library is in flux. APIs may change without notice. Generated from source with koruc 0.1.7 on 11/4/2026.
Rand
import std/randstd/rand — randomness from the host's cryptographic source.
rand.kz · 2 tors
std/rand — randomness from the host's cryptographic source.
The gap this closes: Java's ThreadLocalRandom — ambient, OS-seeded,
no seed threading through your flow. std.crypto.random IS that,
seeded by the OS; these tors are just its honest branch surface.
Usage:
import std/rand
std/rand:between(lo: 1, hi: 7): f |> ...
std/rand:below(n: 6): v |> ...
between
koru_std/rand.kz:18// Uniform integer in [lo, hi) — nextInt(lo, hi). Contract: hi > lo —
// an empty or inverted range is a programmer error, not an outcome, so
// there is no `| empty` to arm at every call site; the zig safety check
// inside intRangeAtMost is the enforcer and panics on violation.
~pub tor between { lo: i64, hi: i64 } -> i64below
koru_std/rand.kz:25// Uniform integer in [0, n) — nextInt(n). Contract: n > 0, same class.
~pub tor below { n: i64 } -> i64