diff options
| author | data-man <datamanrb@gmail.com> | 2020-10-21 22:02:38 +0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-10-26 15:40:48 -0400 |
| commit | 194e29adfccbd5076a3523572c7e119d4bfa647d (patch) | |
| tree | 7a10c9a68cc57f36e59b94e12da47bd9d175cd4b /lib/std | |
| parent | a0f4606f32bab6df88d0afc1bf9ff479470b68cc (diff) | |
| download | zig-194e29adfccbd5076a3523572c7e119d4bfa647d.tar.gz zig-194e29adfccbd5076a3523572c7e119d4bfa647d.zip | |
Format null type in std.fmt
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/fmt.zig | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/std/fmt.zig b/lib/std/fmt.zig index f8bc707bd3..c3f0209e16 100644 --- a/lib/std/fmt.zig +++ b/lib/std/fmt.zig @@ -496,6 +496,7 @@ pub fn formatType( const buffer = [_]u8{'.'} ++ @tagName(value); return formatType(buffer, fmt, options, writer, max_depth); }, + .Null => return formatBuf("null", options, writer), else => @compileError("Unable to format type '" ++ @typeName(T) ++ "'"), } } @@ -1908,3 +1909,9 @@ test "sci float padding" { try testFmt("center-pad: *3.141e+00*\n", "center-pad: {e:*^11.3}\n", .{number}); try testFmt("right-pad: 3.141e+00**\n", "right-pad: {e:*<11.3}\n", .{number}); } + +test "null" { + const inst = null; + try testFmt("null", "{}", .{inst}); +} + |
