build(zig-0.16): update example code in README and examples/ for zig-0.16

This commit is contained in:
CJ van den Berg 2026-04-13 12:13:51 +02:00
parent 82b095bdb8
commit 815146c375
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
4 changed files with 16 additions and 17 deletions

View file

@ -23,11 +23,10 @@ const H = struct {
}
};
pub fn main() !void {
const allocator = std.heap.page_allocator;
pub fn main(init: std.process.Init) !void {
var h = H{ .handler = .{ .vtable = &H.vtable } };
var watcher = try nightwatch.Default.init(allocator, &h.handler);
var watcher = try nightwatch.Default.init(init.io, init.gpa, &h.handler);
defer watcher.deinit();
try watcher.watch(".");
std.Thread.sleep(std.time.ns_per_s * 60);
std.Io.sleep(init.io, std.Io.Duration.fromMilliseconds(60_000), .awake) catch {};
}

View file

@ -38,10 +38,9 @@ const H = struct {
}
};
pub fn main() !void {
const allocator = std.heap.page_allocator;
pub fn main(init: std.process.Init) !void {
var h = H{ .handler = .{ .vtable = &H.vtable } };
var watcher = try Watcher.init(allocator, &h.handler);
var watcher = try Watcher.init(init.io, init.gpa, &h.handler);
defer watcher.deinit();
try watcher.watch(".");

View file

@ -35,11 +35,10 @@ const H = struct {
}
};
pub fn main() !void {
const allocator = std.heap.page_allocator;
pub fn main(init: std.process.Init) !void {
var h = H{ .handler = .{ .vtable = &H.vtable } };
var watcher = try Watcher.init(allocator, &h.handler);
var watcher = try Watcher.init(init.io, init.gpa, &h.handler);
defer watcher.deinit();
try watcher.watch(".");
std.Thread.sleep(std.time.ns_per_s * 60);
std.Io.sleep(init.io, std.Io.Duration.fromMilliseconds(60_000), .awake) catch {};
}