diff options
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/fmt.zig | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/std/fmt.zig b/lib/std/fmt.zig index 8ca7db81e5..485303518a 100644 --- a/lib/std/fmt.zig +++ b/lib/std/fmt.zig @@ -537,7 +537,7 @@ pub fn formatType( .Fn => { return format(writer, "{}@{x}", .{ @typeName(T), @ptrToInt(value) }); }, - .Type => return writer.writeAll(@typeName(T)), + .Type => return formatBuf(@typeName(value), options, writer), .EnumLiteral => { const buffer = [_]u8{'.'} ++ @tagName(value); return formatType(buffer, fmt, options, writer, max_depth); @@ -2052,6 +2052,12 @@ test "null" { try testFmt("null", "{}", .{inst}); } +test "type" { + try testFmt("u8", "{}", .{u8}); + try testFmt("?f32", "{}", .{?f32}); + try testFmt("[]const u8", "{}", .{[]const u8}); +} + test "named arguments" { try testFmt("hello world!", "{} world{c}", .{ "hello", '!' }); try testFmt("hello world!", "{[greeting]} world{[punctuation]c}", .{ .punctuation = '!', .greeting = "hello" }); |
