Commit a471a57560
Changed files (1)
lib
std
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" });