Merge pull request #25714 from snoire/enum-literal-format-support

std.Io.Writer.print: support .enum_literal in 't' format specifier
This commit is contained in:
Ryan Liptak 2025-11-06 14:40:34 -08:00 committed by GitHub
commit 4937aeff84
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 1 deletions

View file

@ -1161,7 +1161,7 @@ pub fn printValue(
}, },
't' => switch (@typeInfo(T)) { 't' => switch (@typeInfo(T)) {
.error_set => return w.alignBufferOptions(@errorName(value), options), .error_set => return w.alignBufferOptions(@errorName(value), options),
.@"enum", .@"union" => return w.alignBufferOptions(@tagName(value), options), .@"enum", .enum_literal, .@"union" => return w.alignBufferOptions(@tagName(value), options),
else => invalidFmtError(fmt, value), else => invalidFmtError(fmt, value),
}, },
else => {}, else => {},

View file

@ -1249,6 +1249,7 @@ test "vector" {
test "enum-literal" { test "enum-literal" {
try expectFmt(".hello_world", "{}", .{.hello_world}); try expectFmt(".hello_world", "{}", .{.hello_world});
try expectFmt("hello_world", "{t}", .{.hello_world});
} }
test "padding" { test "padding" {