commit 1e1f026c8355c8cd4c6efb5b7fc42e5b2091e1f2 (tree)
parent 1ee403ce932ced1d4d5562706e1ec12cc4eb1d87
Author: Andrew Kelley <andrew@ziglang.org>
Date: Mon, 30 Jun 2025 15:36:12 -0700
std.mem.byteSwapAllFields: support slices
Diffstat:
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/std/mem.zig b/lib/std/mem.zig
@@ -1714,7 +1714,7 @@ pub fn readVarInt(comptime ReturnType: type, bytes: []const u8, endian: Endian)
}
},
}
- return @as(ReturnType, @truncate(result));
+ return @truncate(result);
}
test readVarInt {
@@ -2196,7 +2196,9 @@ pub fn byteSwapAllFields(comptime S: type, ptr: *S) void {
}
}
},
- else => @compileError("byteSwapAllFields expects a struct or array as the first argument"),
+ else => {
+ ptr.* = @byteSwap(ptr.*);
+ },
}
}