mirror of
https://github.com/ziglang/zig.git
synced 2026-02-13 04:48:20 +00:00
Fixed failure using readStruct and gave async readStruct the same sig
This commit is contained in:
parent
f4606842d2
commit
3090f83800
@ -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];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user