News Score: Score the News, Sort the News, Rewrite the Headlines

Is Zig's New Writer Unsafe?

If we wanted to write a function that takes one of Zig's new *std.Io.Reader and write it to stdout, we might start with something like: fn output(r: *std.Io.Reader) !void { const stdout = std.fs.File.stdout(); var buffer: [???]u8 = undefined; var writer = stdout.writer(&buffer); _ = try r.stream(&writer.interface, .unlimited); try writer.interface.flush(); } But what should the size of buffer be? If this was a one-and-done, maybe we'd leave it empty or put some seemingly sensible default, like 1...

Read more at openmymind.net

© News Score  score the news, sort the news, rewrite the headlines