From b8cb780230197ce7e7e3059c7e37e1a40d9dcfc2 Mon Sep 17 00:00:00 2001 From: Erik Schlyter Date: Sat, 14 Feb 2026 23:06:28 +0100 Subject: [PATCH] std.Io.Writer: Make Hashing support pointers. The line `const hasher = &this.hasher` was making the local variable `hasher` a double-pointer when `Hasher` already is a pointer to a hasher, which the line `hasher.update` would not dereference. By removing the local `hasher` value we allow `Hashing` to accept pointer types as well. The contrasting `Hashed` function already follows this pattern. --- lib/std/Io/Writer.zig | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/std/Io/Writer.zig b/lib/std/Io/Writer.zig index 0da4d552d58d3939e27387313d0f12d76dc3d7b2..3f6fde21afd53b820714feb5982f2e81c054c7c2 100644 --- a/lib/std/Io/Writer.zig +++ b/lib/std/Io/Writer.zig @@ -2524,15 +2524,14 @@ pub fn Hashing(comptime Hasher: type) type { fn drain(w: *Writer, data: []const []const u8, splat: usize) Error!usize { const this: *@This() = @alignCast(@fieldParentPtr("writer", w)); - const hasher = &this.hasher; - hasher.update(w.buffered()); + this.hasher.update(w.buffered()); w.end = 0; var n: usize = 0; for (data[0 .. data.len - 1]) |slice| { - hasher.update(slice); + this.hasher.update(slice); n += slice.len; } - for (0..splat) |_| hasher.update(data[data.len - 1]); + for (0..splat) |_| this.hasher.update(data[data.len - 1]); return n + splat * data[data.len - 1].len; } }; -- 2.54.0