authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-08-25 19:51:40-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-08-25 19:51:40-07:00
log3e24e958922806379f9f609e36954a489eb20831
treeb975296ccdaccf74d5eb267996b714c8abeaf548
parentb498eebfd450e7579dc8652d5827a23cc7070d9d

std.rand: promote normal comments to doc comments


1 files changed, 18 insertions(+), 17 deletions(-)

lib/std/rand.zig+18-17
...@@ -3,21 +3,22 @@...@@ -3,21 +3,22 @@
3// This file is part of [zig](https://ziglang.org/), which is MIT licensed.3// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
4// The MIT license requires this copyright notice to be included in all copies4// The MIT license requires this copyright notice to be included in all copies
5// and substantial portions of the software.5// and substantial portions of the software.
6// The engines provided here should be initialized from an external source. For now, randomBytes6
7// from the crypto package is the most suitable. Be sure to use a CSPRNG when required, otherwise using7//! The engines provided here should be initialized from an external source. For now, randomBytes
8// a normal PRNG will be faster and use substantially less stack space.8//! from the crypto package is the most suitable. Be sure to use a CSPRNG when required, otherwise using
9//9//! a normal PRNG will be faster and use substantially less stack space.
10// ```10//!
11// var buf: [8]u8 = undefined;11//! ```
12// try std.crypto.randomBytes(buf[0..]);12//! var buf: [8]u8 = undefined;
13// const seed = mem.readIntLittle(u64, buf[0..8]);13//! try std.crypto.randomBytes(buf[0..]);
14//14//! const seed = mem.readIntLittle(u64, buf[0..8]);
15// var r = DefaultPrng.init(seed);15//!
16//16//! var r = DefaultPrng.init(seed);
17// const s = r.random.int(u64);17//!
18// ```18//! const s = r.random.int(u64);
19//19//! ```
20// TODO(tiehuis): Benchmark these against other reference implementations.20//!
21//! TODO(tiehuis): Benchmark these against other reference implementations.
2122
22const std = @import("std.zig");23const std = @import("std.zig");
23const builtin = @import("builtin");24const builtin = @import("builtin");
...@@ -29,10 +30,10 @@ const math = std.math;...@@ -29,10 +30,10 @@ const math = std.math;
29const ziggurat = @import("rand/ziggurat.zig");30const ziggurat = @import("rand/ziggurat.zig");
30const maxInt = std.math.maxInt;31const maxInt = std.math.maxInt;
3132
32// When you need fast unbiased random numbers33/// Fast unbiased random numbers.
33pub const DefaultPrng = Xoroshiro128;34pub const DefaultPrng = Xoroshiro128;
3435
35// When you need cryptographically secure random numbers36/// Cryptographically secure random numbers.
36pub const DefaultCsprng = Isaac64;37pub const DefaultCsprng = Isaac64;
3738
38pub const Random = struct {39pub const Random = struct {