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

@ -81,7 +81,7 @@ The Watch is written in **Zig** and built using the Zig build system.
## Requirements
- Zig (currently zig-0.15.2)
- Zig - zig-0.16.0-dev (master branch) or zig-0.15.2 (zig-0.15 branch)
## Build CLI
@ -145,11 +145,13 @@ const H = struct {
}
};
var h = H{ .handler = .{ .vtable = &H.vtable } };
var watcher = try nightwatch.Default.init(allocator, &h.handler);
defer watcher.deinit();
try watcher.watch("/path/to/dir");
// watcher delivers events on a background thread until deinit()
pub fn main(init: std.process.Init) !void {
var h = H{ .handler = .{ .vtable = &H.vtable } };
var watcher = try nightwatch.Default.init(init.io, init.gpa, &h.handler);
defer watcher.deinit();
try watcher.watch("/path/to/dir");
// watcher delivers events on a background thread until deinit()
}
```
See the [`examples/`](examples/) directory for complete, buildable programs.