| ... | ... | @@ -1986,7 +1986,10 @@ pub const BufPrintError = error{ |
| 1986 | 1986 | /// Returns a slice of the bytes printed to. |
| 1987 | 1987 | pub fn bufPrint(buf: []u8, comptime fmt: []const u8, args: anytype) BufPrintError![]u8 { |
| 1988 | 1988 | var fbs = std.io.fixedBufferStream(buf); |
| 1989 | | try format(fbs.writer(), fmt, args); |
| 1989 | format(fbs.writer().any(), fmt, args) catch |err| switch (err) { |
| 1990 | error.NoSpaceLeft => return error.NoSpaceLeft, |
| 1991 | else => unreachable, |
| 1992 | }; |
| 1990 | 1993 | return fbs.getWritten(); |
| 1991 | 1994 | } |
| 1992 | 1995 | |
| ... | ... | @@ -1998,7 +2001,7 @@ pub fn bufPrintZ(buf: []u8, comptime fmt: []const u8, args: anytype) BufPrintErr |
| 1998 | 2001 | /// Count the characters needed for format. Useful for preallocating memory |
| 1999 | 2002 | pub fn count(comptime fmt: []const u8, args: anytype) u64 { |
| 2000 | 2003 | var counting_writer = std.io.countingWriter(std.io.null_writer); |
| 2001 | | format(counting_writer.writer(), fmt, args) catch |err| switch (err) {}; |
| 2004 | format(counting_writer.writer().any(), fmt, args) catch unreachable; |
| 2002 | 2005 | return counting_writer.bytes_written; |
| 2003 | 2006 | } |
| 2004 | 2007 | |