| ... | @@ -55,7 +55,7 @@ pub fn values(comptime E: type) []const E { | ... | @@ -55,7 +55,7 @@ pub fn values(comptime E: type) []const E { |
| 55 | /// A safe alternative to @tagName() for non-exhaustive enums that doesn't | 55 | /// A safe alternative to @tagName() for non-exhaustive enums that doesn't |
| 56 | /// panic when `e` has no tagged value. | 56 | /// panic when `e` has no tagged value. |
| 57 | /// Returns the tag name for `e` or null if no tag exists. | 57 | /// Returns the tag name for `e` or null if no tag exists. |
| 58 | pub fn tagName(comptime E: type, e: E) ?[]const u8 { | 58 | pub fn tagName(comptime E: type, e: E) ?[:0]const u8 { |
| 59 | return inline for (@typeInfo(E).@"enum".fields) |f| { | 59 | return inline for (@typeInfo(E).@"enum".fields) |f| { |
| 60 | if (@intFromEnum(e) == f.value) break f.name; | 60 | if (@intFromEnum(e) == f.value) break f.name; |
| 61 | } else null; | 61 | } else null; |