Skip to content

std.Io: delete BufferedWriter - #24743

Merged
andrewrk merged 2 commits into
masterfrom
BufferedWriter
Aug 9, 2025
Merged

andrewrk merged 2 commits into
masterfrom
BufferedWriter

Conversation

@andrewrk

@andrewrk andrewrk commented Aug 8, 2025

Copy link
Copy Markdown
Member

Upgrade Guide

-    const stdout_file = std.fs.File.stdout().writer();
-    var bw = std.io.bufferedWriter(stdout_file);
-    const stdout = bw.writer();
+    var stdout_buffer: [4096]u8 = undefined;
+    var stdout_writer = std.fs.File.stdout().writer(&stdout_buffer);
+    const stdout = &stdout_writer.interface;
 
     try stdout.print("Run `zig build test` to run the tests.\n", .{});
 
-    try bw.flush(); // Don't forget to flush!
+    try stdout.flush(); // Don't forget to flush!

Consider making your stdout buffer global.

@andrewrk andrewrk added breaking Implementing this issue could cause existing code to no longer compile or have different behavior. standard library This issue involves writing Zig code for the standard library. release notes This PR should be mentioned in the release notes. labels Aug 8, 2025
@andrewrk andrewrk mentioned this pull request Aug 9, 2025
@andrewrk
andrewrk merged commit 0a1a738 into master Aug 9, 2025
@andrewrk
andrewrk deleted the BufferedWriter branch August 9, 2025 23:28
@alexrp alexrp removed the release notes This PR should be mentioned in the release notes. label Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Implementing this issue could cause existing code to no longer compile or have different behavior. standard library This issue involves writing Zig code for the standard library.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants