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