Render a formatted string into buffer. Returns a slice of buffer
starting at index 0 containing the result, or error.NoSpaceLeft if one or
more bytes were truncated.
See std.Io.Writer.print.
pub fn print(buffer: []u8, comptime format: []const u8, args: anytype) PrintError![]u8
pub fn print(buffer: []u8, comptime format: []const u8, args: anytype) PrintError![]u8 {
var w: std.Io.Writer = .fixed(buffer);
w.print(format, args) catch |err| switch (err) {
error.WriteFailed => return error.NoSpaceLeft,
};
return w.buffered();
}