authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-06-30 15:36:12-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-07-07 22:43:52-07:00
log1e1f026c8355c8cd4c6efb5b7fc42e5b2091e1f2
tree222e1e51cf2b531ff1db02ae542335338277bd78
parent1ee403ce932ced1d4d5562706e1ec12cc4eb1d87

std.mem.byteSwapAllFields: support slices


1 files changed, 4 insertions(+), 2 deletions(-)

lib/std/mem.zig+4-2
......@@ -1714,7 +1714,7 @@ pub fn readVarInt(comptime ReturnType: type, bytes: []const u8, endian: Endian)
17141714 }
17151715 },
17161716 }
1717 return @as(ReturnType, @truncate(result));
1717 return @truncate(result);
17181718}
17191719
17201720test readVarInt {
......@@ -2196,7 +2196,9 @@ pub fn byteSwapAllFields(comptime S: type, ptr: *S) void {
21962196 }
21972197 }
21982198 },
2199 else => @compileError("byteSwapAllFields expects a struct or array as the first argument"),
2199 else => {
2200 ptr.* = @byteSwap(ptr.*);
2201 },
22002202 }
22012203}
22022204