aboutsummaryrefslogtreecommitdiff
path: root/std/io.zig
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-08-25 04:50:51 -0400
committerGitHub <noreply@github.com>2018-08-25 04:50:51 -0400
commit4003cd4747019d79ff50aaa22415d2d3dfc15cf4 (patch)
tree1f77690a5fb7ccbef75bcab9c8c1e008ef3c5068 /std/io.zig
parentbf1f91595d4d3b5911632c671ef16e44d70dc9a6 (diff)
parent815950996dcc92ac6ac285f2005dbac51b9cb6f8 (diff)
downloadzig-4003cd4747019d79ff50aaa22415d2d3dfc15cf4.tar.gz
zig-4003cd4747019d79ff50aaa22415d2d3dfc15cf4.zip
Merge pull request #1406 from ziglang/macos-stack-traces
MacOS stack traces closes #1365
Diffstat (limited to 'std/io.zig')
-rw-r--r--std/io.zig6
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..]));
+ }
};
}