Random Numbers is outdated for zig 0.16

#345 · open · 0 comments

View on GitHub ↗

Swiddis

Not technically a problem since the guide doesn't claim Zig 0.16 support, but: The current content involves loading a seed via `std.posix.getrandom`. As of Zig 0.16, the posix namespace doesn't contain `getrandom`, this functionality has been moved to the [I/O interface](https://ziglang.org/download/0.16.0/release-notes.html#toc-IO-as-an-Interface). prng seeding now looks like this: ```zig pub fn main(init: std.process.Init) !void { var prng: std.Random.DefaultPrng = .init(blk: { var seed: u64 = undefined; init.io.random(std.mem.asBytes(&seed)); break :blk seed; }); const rand = prng.random(); // ... } ``` Just adding this as something to upd when 0.16 is added to the guide (and to help others landing here when the 0.15 guide doesn't work)

Comments