diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-08-24 14:55:55 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-08-24 14:55:55 -0400 |
| commit | 4e7c255e4dde7e059e84605b7f4281d59a5b5b9c (patch) | |
| tree | 0e609dbdb4d7319c7d7ca1e8705c31a4b3a0959f /std/io.zig | |
| parent | 95e197667e52d0e9b772b00fb2118414eead05aa (diff) | |
| download | zig-4e7c255e4dde7e059e84605b7f4281d59a5b5b9c.tar.gz zig-4e7c255e4dde7e059e84605b7f4281d59a5b5b9c.zip | |
macos stack traces have address-to-line translation
Diffstat (limited to 'std/io.zig')
| -rw-r--r-- | std/io.zig | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/std/io.zig b/std/io.zig index c7154065cb..369f6eede3 100644 --- a/std/io.zig +++ b/std/io.zig @@ -207,6 +207,12 @@ pub fn InStream(comptime ReadError: type) type { _ = try self.readByte(); } } + + pub fn readStruct(self: *Self, comptime T: type, ptr: *T) !void { + // Only extern and packed structs have defined in-memory layout. + assert(@typeInfo(T).Struct.layout != builtin.TypeInfo.ContainerLayout.Auto); + return self.readNoEof(@sliceToBytes((*[1]T)(ptr)[0..])); + } }; } |
