Commit 426a377c7b

Andrew Kelley <andrew@ziglang.org>
2025-10-15 20:00:33
std.Io.net.Stream: add "const" variant to "close"
useful for resource management
1 parent 80069c1
Changed files (1)
lib
std
lib/std/Io/net.zig
@@ -1154,6 +1154,11 @@ pub const Stream = struct {
         s.* = undefined;
     }
 
+    /// Same as `close` but doesn't try to set `Stream` to `undefined`.
+    pub fn closeConst(s: *const Stream, io: Io) void {
+        io.vtable.netClose(io.userdata, s.socket.handle);
+    }
+
     pub const Reader = struct {
         io: Io,
         interface: Io.Reader,