mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
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:
commit
4937aeff84
2 changed files with 2 additions and 1 deletions
|
|
@ -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 => {},
|
||||||
|
|
|
||||||
|
|
@ -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" {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue