Skip to content

Commit 1e0739f

Browse files
190nalexrp
authored andcommitted
std.enums.tagName: preserve sentinel in return value
1 parent 5f7dfc3 commit 1e0739f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/std/enums.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ pub fn values(comptime E: type) []const E {
5555
/// A safe alternative to @tagName() for non-exhaustive enums that doesn't
5656
/// panic when `e` has no tagged value.
5757
/// 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 {
5959
return inline for (@typeInfo(E).@"enum".fields) |f| {
6060
if (@intFromEnum(e) == f.value) break f.name;
6161
} else null;

0 commit comments

Comments
 (0)