diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-10-08 15:47:45 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-10-08 15:47:45 -0700 |
| commit | 8b7539bd9554d25599ccff6f0e9ea79aa051946b (patch) | |
| tree | 9157fafcbe37f904346fd73042be1d1d299d4da2 /lib/std/fmt.zig | |
| parent | b5a36f676b1fd69f195d9f1eb6e35f3eb2f15946 (diff) | |
| parent | b02341d6f58e0b8a87fc2ab589dcfd85e5dc96cd (diff) | |
| download | zig-8b7539bd9554d25599ccff6f0e9ea79aa051946b.tar.gz zig-8b7539bd9554d25599ccff6f0e9ea79aa051946b.zip | |
Merge remote-tracking branch 'origin/master' into llvm11
Conflicts:
src/clang.zig
Master branch renamed an enum; this branch gave it an explicit tag type
and explicitly initialized values. This commit combines the changes
together.
Diffstat (limited to 'lib/std/fmt.zig')
| -rw-r--r-- | lib/std/fmt.zig | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/std/fmt.zig b/lib/std/fmt.zig index ab2cc1577d..ce90f67585 100644 --- a/lib/std/fmt.zig +++ b/lib/std/fmt.zig @@ -1181,13 +1181,16 @@ fn bufPrintIntToSlice(buf: []u8, value: anytype, base: u8, uppercase: bool, opti return buf[0..formatIntBuf(buf, value, base, uppercase, options)]; } -pub fn comptimePrint(comptime fmt: []const u8, args: anytype) *const [count(fmt, args)]u8 { - comptime var buf: [count(fmt, args)]u8 = undefined; +pub fn comptimePrint(comptime fmt: []const u8, args: anytype) *const [count(fmt, args):0]u8 { + comptime var buf: [count(fmt, args):0]u8 = undefined; _ = bufPrint(&buf, fmt, args) catch unreachable; + buf[buf.len] = 0; return &buf; } test "comptimePrint" { + @setEvalBranchQuota(2000); + std.testing.expectEqual(*const [3:0]u8, @TypeOf(comptime comptimePrint("{}", .{100}))); std.testing.expectEqualSlices(u8, "100", comptime comptimePrint("{}", .{100})); } |
