std.fmt.comptimePrint: Return null terminated string
This commit is contained in:
parent
7f7e2d608a
commit
49e68bdcf3
@ -1181,8 +1181,8 @@ fn bufPrintIntToSlice(buf: []u8, value: anytype, base: u8, uppercase: bool, opti
|
|||||||
return buf[0..formatIntBuf(buf, value, base, uppercase, options)];
|
return buf[0..formatIntBuf(buf, value, base, uppercase, options)];
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn comptimePrint(comptime fmt: []const u8, args: anytype) *const [count(fmt, args)]u8 {
|
pub fn comptimePrint(comptime fmt: []const u8, args: anytype) *const [count(fmt, args):0]u8 {
|
||||||
comptime var buf: [count(fmt, args)]u8 = undefined;
|
comptime var buf: [count(fmt, args):0]u8 = undefined;
|
||||||
_ = bufPrint(&buf, fmt, args) catch unreachable;
|
_ = bufPrint(&buf, fmt, args) catch unreachable;
|
||||||
return &buf;
|
return &buf;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user