| ... | @@ -491,6 +491,13 @@ pub fn formatType( | ... | @@ -491,6 +491,13 @@ pub fn formatType( |
| 491 | return format(context, Errors, output, "{}@{x}", .{ @typeName(T), @ptrToInt(value) }); | 491 | return format(context, Errors, output, "{}@{x}", .{ @typeName(T), @ptrToInt(value) }); |
| 492 | }, | 492 | }, |
| 493 | .Type => return output(context, @typeName(T)), | 493 | .Type => return output(context, @typeName(T)), |
| | 494 | .EnumLiteral => { |
| | 495 | const name = @tagName(value); |
| | 496 | var buffer: [name.len + 1]u8 = undefined; |
| | 497 | buffer[0] = '.'; |
| | 498 | std.mem.copy(u8, buffer[1..], name); |
| | 499 | return formatType(buffer, fmt, options, context, Errors, output, max_depth); |
| | 500 | }, |
| 494 | else => @compileError("Unable to format type '" ++ @typeName(T) ++ "'"), | 501 | else => @compileError("Unable to format type '" ++ @typeName(T) ++ "'"), |
| 495 | } | 502 | } |
| 496 | } | 503 | } |
| ... | @@ -1744,3 +1751,7 @@ test "vector" { | ... | @@ -1744,3 +1751,7 @@ test "vector" { |
| 1744 | try testFmt("{ 1kB, 2kB, 3kB, 4kB }", "{B}", .{vu64}); | 1751 | try testFmt("{ 1kB, 2kB, 3kB, 4kB }", "{B}", .{vu64}); |
| 1745 | try testFmt("{ 1000B, 1.953125KiB, 2.9296875KiB, 3.90625KiB }", "{Bi}", .{vu64}); | 1752 | try testFmt("{ 1000B, 1.953125KiB, 2.9296875KiB, 3.90625KiB }", "{Bi}", .{vu64}); |
| 1746 | } | 1753 | } |
| | 1754 | |
| | 1755 | test "enum-literal" { |
| | 1756 | try testFmt(".hello_world", "{}", .{.hello_world}); |
| | 1757 | } |