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)...@@ -1714,7 +1714,7 @@ pub fn readVarInt(comptime ReturnType: type, bytes: []const u8, endian: Endian)
1714 }1714 }
1715 },1715 },
1716 }1716 }
1717 return @as(ReturnType, @truncate(result));1717 return @truncate(result);
1718}1718}
17191719
1720test readVarInt {1720test readVarInt {
...@@ -2196,7 +2196,9 @@ pub fn byteSwapAllFields(comptime S: type, ptr: *S) void {...@@ -2196,7 +2196,9 @@ pub fn byteSwapAllFields(comptime S: type, ptr: *S) void {
2196 }2196 }
2197 }2197 }
2198 },2198 },
2199 else => @compileError("byteSwapAllFields expects a struct or array as the first argument"),2199 else => {
2200 ptr.* = @byteSwap(ptr.*);
2201 },
2200 }2202 }
2201}2203}
22022204