Trying to call a function from outside of a struct that contains a public function doesn't seem to work. I'm sure there's a way, I just don't understand how.
src\main.zig:29:27: error: use of undeclared identifier 'updater'
var update_instance = updater{};
var update_instance = updater{};
var serve_instance = server{};
const server = struct {
pub fn serve() !void {
if (unserved > 0) {
unserved -= 1;
served += 1;
std.debug.print("Serving guest. Served: {d}, Unserved: {d}\n", .{ served, unserved });
if (std.rand.random().int(u32) < 5) {
new_guest = std.time.milli(std.rand.random().intRange(1000, 10000));
}
}
.serve;
}
};
const updater = struct {
pub fn update() !void {
if (new_guest <= 0) {
new_guest = std.time.milli(std.rand.random().intRange(1000, 10000));
std.debug.print("New guest arrived!\n", .{});
}
.update;
}
};
Maybe I'm doing it wrong, anyone got a solution and explanation? And preferably a docs link where I can read up a bit more about how it works in-depth? This is week 3 of trying to learn Zig (I allocate 1 1/2 hours a week to learning).