diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-12-18 23:57:46 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-18 23:57:46 -0500 |
| commit | 506af7e52e0985b410ea089bf5fa3247ab2377cb (patch) | |
| tree | 2ec26d70f41a1382b736b606ebfa094ace62573e /lib/std/meta.zig | |
| parent | ce65533985caa9e2da567948e36d7d4ba0185005 (diff) | |
| parent | f416535768fc30195cad6cd481f73fd1e80082aa (diff) | |
| download | zig-506af7e52e0985b410ea089bf5fa3247ab2377cb.tar.gz zig-506af7e52e0985b410ea089bf5fa3247ab2377cb.zip | |
Merge pull request #7482 from ziglang/tlcsprng
std: introduce a thread-local CSPRNG for general use
Diffstat (limited to 'lib/std/meta.zig')
| -rw-r--r-- | lib/std/meta.zig | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/std/meta.zig b/lib/std/meta.zig index 2cf7f6de81..d51a2744b3 100644 --- a/lib/std/meta.zig +++ b/lib/std/meta.zig @@ -9,6 +9,7 @@ const debug = std.debug; const mem = std.mem; const math = std.math; const testing = std.testing; +const root = @import("root"); pub const trait = @import("meta/trait.zig"); pub const TrailerFlags = @import("meta/trailer_flags.zig").TrailerFlags; @@ -1085,3 +1086,10 @@ test "Tuple" { TupleTester.assertTuple(.{ u32, f16 }, Tuple(&[_]type{ u32, f16 })); TupleTester.assertTuple(.{ u32, f16, []const u8, void }, Tuple(&[_]type{ u32, f16, []const u8, void })); } + +/// TODO: https://github.com/ziglang/zig/issues/425 +pub fn globalOption(comptime name: []const u8, comptime T: type) ?T { + if (!@hasDecl(root, name)) + return null; + return @as(T, @field(root, name)); +} |
