authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2020-06-11 22:31:08+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2020-06-11 22:31:08+02:00
logc7721bb3688dd5f69700c7a54b5ad30f8d1482e6
tree7eec8da5df950a80b8187843dd626c8973292fd2
parente4a8598ddda0d0ff289ac59a04f2ac965ef7e102

Add custom format method for Preopen struct


1 files changed, 8 insertions(+), 0 deletions(-)

lib/std/fs/wasi.zig+8
...@@ -35,6 +35,14 @@ pub const Preopen = struct {...@@ -35,6 +35,14 @@ pub const Preopen = struct {
35 .@"type" = .{ .Dir = path },35 .@"type" = .{ .Dir = path },
36 };36 };
37 }37 }
38
39 pub fn format(self: Self, comptime fmt: []const u8, options: std.fmt.FormatOptions, out_stream: var) !void {
40 try out_stream.print("{{ .fd = {}, ", .{self.fd});
41 switch (self.@"type") {
42 PreopenType.Dir => |path| try out_stream.print(".Dir = '{}'", .{path}),
43 }
44 return out_stream.print(" }}", .{});
45 }
38};46};
3947
40/// Dynamically-sized array list of WASI preopens. This struct is a48/// Dynamically-sized array list of WASI preopens. This struct is a