Skip to content

Commit 4937aef

Browse files
authored
Merge pull request #25714 from snoire/enum-literal-format-support
std.Io.Writer.print: support .enum_literal in 't' format specifier
2 parents b2895f3 + b4b54b5 commit 4937aef

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

lib/std/Io/Writer.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,7 @@ pub fn printValue(
11611161
},
11621162
't' => switch (@typeInfo(T)) {
11631163
.error_set => return w.alignBufferOptions(@errorName(value), options),
1164-
.@"enum", .@"union" => return w.alignBufferOptions(@tagName(value), options),
1164+
.@"enum", .enum_literal, .@"union" => return w.alignBufferOptions(@tagName(value), options),
11651165
else => invalidFmtError(fmt, value),
11661166
},
11671167
else => {},

lib/std/fmt.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,6 +1249,7 @@ test "vector" {
12491249

12501250
test "enum-literal" {
12511251
try expectFmt(".hello_world", "{}", .{.hello_world});
1252+
try expectFmt("hello_world", "{t}", .{.hello_world});
12521253
}
12531254

12541255
test "padding" {

0 commit comments

Comments
 (0)