From 3b73a8edaff14039d917b1958715d1d54659851b Mon Sep 17 00:00:00 2001 From: Jimmi Holst Christensen Date: Wed, 7 Jan 2026 21:01:09 +0100 Subject: chore: Update examples in README to use new std.Io --- example/simple.zig | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'example/simple.zig') diff --git a/example/simple.zig b/example/simple.zig index 67313aa..a7772c6 100644 --- a/example/simple.zig +++ b/example/simple.zig @@ -1,6 +1,10 @@ pub fn main() !void { - var gpa = std.heap.DebugAllocator(.{}){}; - defer _ = gpa.deinit(); + var gpa_state = std.heap.DebugAllocator(.{}){}; + const gpa = gpa_state.allocator(); + defer _ = gpa_state.deinit(); + + var threaded: std.Io.Threaded = .init_single_threaded; + const io: std.Io = threaded.io(); // First we specify what parameters our program can take. // We can use `parseParamsComptime` to parse a string into an array of `Param(Help)`. @@ -16,11 +20,9 @@ pub fn main() !void { // This is optional. You can also pass `.{}` to `clap.parse` if you don't // care about the extra information `Diagnostics` provides. var diag = clap.Diagnostic{}; - var threaded: std.Io.Threaded = .init_single_threaded; - const io: std.Io = threaded.io(); var res = clap.parse(clap.Help, ¶ms, clap.parsers.default, .{ .diagnostic = &diag, - .allocator = gpa.allocator(), + .allocator = gpa, }) catch |err| { // Report useful error and exit. try diag.reportToFile(io, .stderr(), err); -- cgit v1.2.3