Commit 3090f83800

Jimmi HC <jimmiholstchristensen@gmail.com>
2018-11-15 21:59:17
Fixed failure using readStruct and gave async readStruct the same sig
1 parent f460684
Changed files (2)
std
std/event/io.zig
@@ -53,10 +53,12 @@ pub fn InStream(comptime ReadError: type) type {
             return mem.readInt(bytes, T, endian);
         }
 
-        pub async fn readStruct(self: *Self, comptime T: type, ptr: *T) !void {
+        pub async fn readStruct(self: *Self, comptime T: type) !T {
             // Only extern and packed structs have defined in-memory layout.
             comptime assert(@typeInfo(T).Struct.layout != builtin.TypeInfo.ContainerLayout.Auto);
-            return await (async self.readNoEof(@sliceToBytes((*[1]T)(ptr)[0..])) catch unreachable);
+            var res: [1]T = undefined;
+            try await (async self.readNoEof(@sliceToBytes(res[0..])) catch unreachable);
+            return res[0];
         }
     };
 }
std/pdb.zig
@@ -485,8 +485,7 @@ const Msf = struct {
         var file_stream = file.inStream();
         const in = &file_stream.stream;
 
-        var superblock: SuperBlock = undefined;
-        try in.readStruct(SuperBlock, &superblock);
+        const superblock = try in.readStruct(SuperBlock);
 
         if (!mem.eql(u8, superblock.FileMagic, SuperBlock.file_magic))
             return error.InvalidDebugInfo;