| ... | @@ -188,10 +188,12 @@ pub fn InStream(comptime ReadError: type) type { | ... | @@ -188,10 +188,12 @@ pub fn InStream(comptime ReadError: type) type { |
| 188 | } | 188 | } |
| 189 | } | 189 | } |
| 190 | | 190 | |
| 191 | pub fn readStruct(self: *Self, comptime T: type, ptr: *T) !void { | 191 | pub fn readStruct(self: *Self, comptime T: type) !T { |
| 192 | // Only extern and packed structs have defined in-memory layout. | 192 | // Only extern and packed structs have defined in-memory layout. |
| 193 | comptime assert(@typeInfo(T).Struct.layout != builtin.TypeInfo.ContainerLayout.Auto); | 193 | comptime assert(@typeInfo(T).Struct.layout != builtin.TypeInfo.ContainerLayout.Auto); |
| 194 | return self.readNoEof(@sliceToBytes((*[1]T)(ptr)[0..])); | 194 | var res: [1]T = undefined; |
| | 195 | return self.readNoEof(@sliceToBytes(res[0..])); |
| | 196 | return res[0]; |
| 195 | } | 197 | } |
| 196 | }; | 198 | }; |
| 197 | } | 199 | } |