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