From 1e1f026c8355c8cd4c6efb5b7fc42e5b2091e1f2 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 30 Jun 2025 15:36:12 -0700 Subject: [PATCH] std.mem.byteSwapAllFields: support slices --- lib/std/mem.zig | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/std/mem.zig b/lib/std/mem.zig index 59c26cc887..a5613536c6 100644 --- 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.*); + }, } }