Hi, I am trying to walk directories using walk function from stdlib. However, I don’t know the correct way to use it. Use the following code gives me error blablabla does not support field access
zig version: 0.9.1
Code:
const std = @import("std");
const fs = std.fs;
pub fn main() !void {
const allocator = std.testing.allocator;
const dir = try fs.cwd().openDir(".", .{ .iterate = true });
var walker = dir.walk(allocator);
defer walker.deinit();
while (try walker.next()) |entry| {
std.debug.print("{s}\n", .{entry.basename});
}
}
Error:
./src/main.zig:29:22: error: type '@typeInfo(@typeInfo(@TypeOf(std.fs.Dir.walk)).Fn.return_type.?).ErrorUnion.error_set!std.fs.Walker' does not support field access
while (try walker.next()) |entry| {
^