1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

rand: extend PRNG interface, add buffering support (#13608)

This commit is contained in:
Subhomoy Haldar
2022-02-28 16:47:54 +05:30
committed by GitHub
parent efeb3e04da
commit a0d9e6e1c2
9 changed files with 380 additions and 110 deletions

View File

@@ -66,9 +66,8 @@ pub fn ulid_at_millisecond(unix_time_milli u64) string {
return res
}
// read fills in `buf` a maximum of `buf.len` random bytes
pub fn read(mut buf []byte) {
fn read_internal(mut rng PRNG, mut buf []byte) {
for i in 0 .. buf.len {
buf[i] = byte(default_rng.u32())
buf[i] = rng.byte()
}
}