aboutsummaryrefslogtreecommitdiff
path: root/lib/std/meta.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-12-16 18:06:00 -0700
committerAndrew Kelley <andrew@ziglang.org>2023-01-02 16:57:15 -0700
commit942b5b468fe0a517618b62f0260d3a32c7cc642e (patch)
tree02358931e04082da37565ff53d4545da812d141b /lib/std/meta.zig
parent93ab8be8d8464452af6d2e686e91be2c1da98979 (diff)
downloadzig-942b5b468fe0a517618b62f0260d3a32c7cc642e.tar.gz
zig-942b5b468fe0a517618b62f0260d3a32c7cc642e.zip
std.crypto.tls: implement the rest of the cipher suites
Also: * Use KeyPair.create() function * Don't bother with CCM
Diffstat (limited to 'lib/std/meta.zig')
-rw-r--r--lib/std/meta.zig12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/std/meta.zig b/lib/std/meta.zig
index 39d561469f..db284f8b61 100644
--- a/lib/std/meta.zig
+++ b/lib/std/meta.zig
@@ -810,21 +810,25 @@ test "std.meta.activeTag" {
const TagPayloadType = TagPayload;
-///Given a tagged union type, and an enum, return the type of the union
-/// field corresponding to the enum tag.
-pub fn TagPayload(comptime U: type, comptime tag: Tag(U)) type {
+pub fn TagPayloadByName(comptime U: type, comptime tag_name: []const u8) type {
comptime debug.assert(trait.is(.Union)(U));
const info = @typeInfo(U).Union;
inline for (info.fields) |field_info| {
- if (comptime mem.eql(u8, field_info.name, @tagName(tag)))
+ if (comptime mem.eql(u8, field_info.name, tag_name))
return field_info.type;
}
unreachable;
}
+/// Given a tagged union type, and an enum, return the type of the union field
+/// corresponding to the enum tag.
+pub fn TagPayload(comptime U: type, comptime tag: Tag(U)) type {
+ return TagPayloadByName(U, @tagName(tag));
+}
+
test "std.meta.TagPayload" {
const Event = union(enum) {
Moved: struct {