| ... | @@ -1181,6 +1181,16 @@ fn bufPrintIntToSlice(buf: []u8, value: anytype, base: u8, uppercase: bool, opti | ... | @@ -1181,6 +1181,16 @@ fn bufPrintIntToSlice(buf: []u8, value: anytype, base: u8, uppercase: bool, opti |
| 1181 | return buf[0..formatIntBuf(buf, value, base, uppercase, options)]; | 1181 | return buf[0..formatIntBuf(buf, value, base, uppercase, options)]; |
| 1182 | } | 1182 | } |
| 1183 | | 1183 | |
| | 1184 | pub fn comptimePrint(comptime fmt: []const u8, args: anytype) *const [count(fmt, args)]u8 { |
| | 1185 | comptime var buf: [count(fmt, args)]u8 = undefined; |
| | 1186 | _ = bufPrint(&buf, fmt, args) catch |err| @compileError(err); |
| | 1187 | return &buf; |
| | 1188 | } |
| | 1189 | |
| | 1190 | test "comptimePrint" { |
| | 1191 | std.testing.expectEqualSlices(u8, "100", comptime comptimePrint("{}", .{100})); |
| | 1192 | } |
| | 1193 | |
| 1184 | test "parse u64 digit too big" { | 1194 | test "parse u64 digit too big" { |
| 1185 | _ = parseUnsigned(u64, "123a", 10) catch |err| { | 1195 | _ = parseUnsigned(u64, "123a", 10) catch |err| { |
| 1186 | if (err == error.InvalidCharacter) return; | 1196 | if (err == error.InvalidCharacter) return; |