authorgravatar for datamanrb@gmail.comdata-man <datamanrb@gmail.com> 2020-10-21 22:02:38+05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-10-26 15:40:48-04:00
log194e29adfccbd5076a3523572c7e119d4bfa647d
tree7a10c9a68cc57f36e59b94e12da47bd9d175cd4b
parenta0f4606f32bab6df88d0afc1bf9ff479470b68cc

Format null type in std.fmt


1 files changed, 7 insertions(+), 0 deletions(-)

lib/std/fmt.zig+7
...@@ -496,6 +496,7 @@ pub fn formatType(...@@ -496,6 +496,7 @@ pub fn formatType(
496 const buffer = [_]u8{'.'} ++ @tagName(value);496 const buffer = [_]u8{'.'} ++ @tagName(value);
497 return formatType(buffer, fmt, options, writer, max_depth);497 return formatType(buffer, fmt, options, writer, max_depth);
498 },498 },
499 .Null => return formatBuf("null", options, writer),
499 else => @compileError("Unable to format type '" ++ @typeName(T) ++ "'"),500 else => @compileError("Unable to format type '" ++ @typeName(T) ++ "'"),
500 }501 }
501}502}
...@@ -1908,3 +1909,9 @@ test "sci float padding" {...@@ -1908,3 +1909,9 @@ test "sci float padding" {
1908 try testFmt("center-pad: *3.141e+00*\n", "center-pad: {e:*^11.3}\n", .{number});1909 try testFmt("center-pad: *3.141e+00*\n", "center-pad: {e:*^11.3}\n", .{number});
1909 try testFmt("right-pad: 3.141e+00**\n", "right-pad: {e:*<11.3}\n", .{number});1910 try testFmt("right-pad: 3.141e+00**\n", "right-pad: {e:*<11.3}\n", .{number});
1910}1911}
1912
1913test "null" {
1914 const inst = null;
1915 try testFmt("null", "{}", .{inst});
1916}
1917