authorgravatar for 35231115+Rocknest@users.noreply.github.comRocknest <35231115+Rocknest@users.noreply.github.com> 2020-10-11 17:06:46+03:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-10-14 01:03:01-04:00
log548fd6e87bb8edf20f5ea69b866f8b13f9ad2787
tree23e6779fa78fb6437cc26a25ef9503d0bf59e547
parent3811602ad72ed1823e06d2e6d2cb646bc81ca5f9

force comptime on comptimePrint


1 files changed, 6 insertions(+), 4 deletions(-)

lib/std/fmt.zig+6-4
...@@ -1182,10 +1182,12 @@ fn bufPrintIntToSlice(buf: []u8, value: anytype, base: u8, uppercase: bool, opti...@@ -1182,10 +1182,12 @@ fn bufPrintIntToSlice(buf: []u8, value: anytype, base: u8, uppercase: bool, opti
1182}1182}
11831183
1184pub fn comptimePrint(comptime fmt: []const u8, args: anytype) *const [count(fmt, args):0]u8 {1184pub fn comptimePrint(comptime fmt: []const u8, args: anytype) *const [count(fmt, args):0]u8 {
1185 comptime var buf: [count(fmt, args):0]u8 = undefined;1185 comptime {
1186 _ = bufPrint(&buf, fmt, args) catch unreachable;1186 var buf: [count(fmt, args):0]u8 = undefined;
1187 buf[buf.len] = 0;1187 _ = bufPrint(&buf, fmt, args) catch unreachable;
1188 return &buf;1188 buf[buf.len] = 0;
1189 return &buf;
1190 }
1189}1191}
11901192
1191test "comptimePrint" {1193test "comptimePrint" {