aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2025-06-30 15:36:12 -0700
committerAndrew Kelley <andrew@ziglang.org>2025-07-07 22:43:52 -0700
commit1e1f026c8355c8cd4c6efb5b7fc42e5b2091e1f2 (patch)
tree222e1e51cf2b531ff1db02ae542335338277bd78 /lib/std
parent1ee403ce932ced1d4d5562706e1ec12cc4eb1d87 (diff)
downloadzig-1e1f026c8355c8cd4c6efb5b7fc42e5b2091e1f2.tar.gz
zig-1e1f026c8355c8cd4c6efb5b7fc42e5b2091e1f2.zip
std.mem.byteSwapAllFields: support slices
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/mem.zig6
1 files 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.*);
+ },
}
}