authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2023-05-05 00:17:18-07:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2023-05-10 16:00:14+03:00
log0972196f4d9e583a1086a5cba41bf7918b1962c0
tree4806b2247b3817ba152640e3c3ca87fc3163c7f9
parent11fabc4cbee7addbdb86d6ba0297abe8274bbbb4

std.meta: remove tagName

not used by Zig itself anywhere

1 files changed, 1 insertions(+), 42 deletions(-)

lib/std/meta.zig+1-42
...@@ -14,48 +14,7 @@ test {...@@ -14,48 +14,7 @@ test {
14 _ = TrailerFlags;14 _ = TrailerFlags;
15}15}
1616
17pub fn tagName(v: anytype) []const u8 {17pub const tagName = @compileError("deprecated; use @tagName or @errorName directly");
18 const T = @TypeOf(v);
19 switch (@typeInfo(T)) {
20 .ErrorSet => return @errorName(v),
21 else => return @tagName(v),
22 }
23}
24
25test "std.meta.tagName" {
26 const E1 = enum {
27 A,
28 B,
29 };
30 const E2 = enum(u8) {
31 C = 33,
32 D,
33 };
34 const U1 = union(enum) {
35 G: u8,
36 H: u16,
37 };
38 const U2 = union(E2) {
39 C: u8,
40 D: u16,
41 };
42
43 var u1g = U1{ .G = 0 };
44 var u1h = U1{ .H = 0 };
45 var u2a = U2{ .C = 0 };
46 var u2b = U2{ .D = 0 };
47
48 try testing.expect(mem.eql(u8, tagName(E1.A), "A"));
49 try testing.expect(mem.eql(u8, tagName(E1.B), "B"));
50 try testing.expect(mem.eql(u8, tagName(E2.C), "C"));
51 try testing.expect(mem.eql(u8, tagName(E2.D), "D"));
52 try testing.expect(mem.eql(u8, tagName(error.E), "E"));
53 try testing.expect(mem.eql(u8, tagName(error.F), "F"));
54 try testing.expect(mem.eql(u8, tagName(u1g), "G"));
55 try testing.expect(mem.eql(u8, tagName(u1h), "H"));
56 try testing.expect(mem.eql(u8, tagName(u2a), "C"));
57 try testing.expect(mem.eql(u8, tagName(u2b), "D"));
58}
5918
60/// Given an enum or tagged union, returns true if the comptime-supplied19/// Given an enum or tagged union, returns true if the comptime-supplied
61/// string matches the name of the tag value. This match process should20/// string matches the name of the tag value. This match process should