blob dbc49fdc (965B) - Raw
1 #target=x86_64-linux-selfhosted 2 //#target=x86_64-windows-selfhosted 3 #target=x86_64-linux-llvm 4 //#target=wasm32-wasi-selfhosted 5 #update=initial version 6 #file=main.zig 7 const std = @import("std"); 8 const io = std.Io.Threaded.global_single_threaded.io(); 9 fn Printer(message: []const u8) type { 10 return struct { 11 fn print() !void { 12 try std.Io.File.stdout().writeStreamingAll(io, message); 13 } 14 }; 15 } 16 pub fn main() !void { 17 try Printer("foo\n").print(); 18 try Printer("bar\n").print(); 19 } 20 #expect_stdout="foo\nbar\n" 21 #update=change line number 22 #file=main.zig 23 const std = @import("std"); 24 const io = std.Io.Threaded.global_single_threaded.io(); 25 26 fn Printer(message: []const u8) type { 27 return struct { 28 fn print() !void { 29 try std.Io.File.stdout().writeStreamingAll(io, message); 30 } 31 }; 32 } 33 pub fn main() !void { 34 try Printer("foo\n").print(); 35 try Printer("bar\n").print(); 36 } 37 #expect_stdout="foo\nbar\n"