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/streaming-clap.zig | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'example/streaming-clap.zig') diff --git a/example/streaming-clap.zig b/example/streaming-clap.zig index c58cd24..9d0a3ca 100644 --- a/example/streaming-clap.zig +++ b/example/streaming-clap.zig @@ -1,5 +1,10 @@ pub fn main() !void { - const allocator = std.heap.page_allocator; + 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. const params = [_]clap.Param(u8){ @@ -15,7 +20,7 @@ pub fn main() !void { .{ .id = 'f', .takes_value = .one }, }; - var iter = try std.process.ArgIterator.initWithAllocator(allocator); + var iter = try std.process.ArgIterator.initWithAllocator(gpa); defer iter.deinit(); // Skip exe argument. @@ -31,9 +36,6 @@ pub fn main() !void { .diagnostic = &diag, }; - var threaded: std.Io.Threaded = .init_single_threaded; - const io: std.Io = threaded.io(); - // Because we use a streaming parser, we have to consume each argument parsed individually. while (parser.next() catch |err| { // Report useful error and exit. -- cgit v1.2.3