aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authorRocknest <35231115+Rocknest@users.noreply.github.com>2020-10-11 17:06:46 +0300
committerAndrew Kelley <andrew@ziglang.org>2020-10-14 01:03:01 -0400
commit548fd6e87bb8edf20f5ea69b866f8b13f9ad2787 (patch)
tree23e6779fa78fb6437cc26a25ef9503d0bf59e547 /lib/std
parent3811602ad72ed1823e06d2e6d2cb646bc81ca5f9 (diff)
downloadzig-548fd6e87bb8edf20f5ea69b866f8b13f9ad2787.tar.gz
zig-548fd6e87bb8edf20f5ea69b866f8b13f9ad2787.zip
force comptime on comptimePrint
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/fmt.zig10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/std/fmt.zig b/lib/std/fmt.zig
index ce90f67585..92e5f9c392 100644
--- a/lib/std/fmt.zig
+++ b/lib/std/fmt.zig
@@ -1182,10 +1182,12 @@ fn bufPrintIntToSlice(buf: []u8, value: anytype, base: u8, uppercase: bool, opti
}
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;
+ comptime {
+ var buf: [count(fmt, args):0]u8 = undefined;
+ _ = bufPrint(&buf, fmt, args) catch unreachable;
+ buf[buf.len] = 0;
+ return &buf;
+ }
}
test "comptimePrint" {