| ... | ... | @@ -1192,8 +1192,6 @@ pub fn peekStructPointer(r: *Reader, comptime T: type) Error!*align(1) T { |
| 1192 | 1192 | return @ptrCast(try r.peekArray(@sizeOf(T))); |
| 1193 | 1193 | } |
| 1194 | 1194 | |
| 1195 | | /// Asserts the buffer was initialized with a capacity at least `@sizeOf(T)`. |
| 1196 | | /// |
| 1197 | 1195 | /// This function is inline to avoid referencing `std.mem.byteSwapAllFields` |
| 1198 | 1196 | /// when `endian` is comptime-known and matches the host endianness. |
| 1199 | 1197 | /// |
| ... | ... | @@ -1205,7 +1203,8 @@ pub inline fn takeStruct(r: *Reader, comptime T: type, endian: std.builtin.Endia |
| 1205 | 1203 | .@"struct" => |info| switch (info.layout) { |
| 1206 | 1204 | .auto => @compileError("ill-defined memory layout"), |
| 1207 | 1205 | .@"extern" => { |
| 1208 | | var res = (try r.takeStructPointer(T)).*; |
| 1206 | var res: T = undefined; |
| 1207 | try r.readSliceAll(std.mem.asBytes(&res)); |
| 1209 | 1208 | if (native_endian != endian) std.mem.byteSwapAllFields(T, &res); |
| 1210 | 1209 | return res; |
| 1211 | 1210 | }, |