Hi,
I’m new to Zig, and I think I need some hints into the right direction. So…
I have a struct
const WriteJob = struct {
priority: i64,
task: *WriteTask,
};
and WriteTask is declared as
const WriteTask = fn (params: []const u8) void;
and I have defined 2 functions:
fn writeCustomer(params: []const u8) void {
std.debug.print("Customer {s}", .{params});
}
fn writeInvoce(params: []const u8) void {
std.debug.print("Invoice No. {s} ", .{params});
}
In the main function I want to create an Arraylist with 1 or more entries of that struct WriteJob.
pub fn main() !void {
var queue = std.ArrayList(WriteJob).init(allocator);
queue.append(.{ .priority = 100, .task = writeCustomer("Norbert Nudel") });
}
When I compile that, I got the following error:
src/main.zig:30:44: error: expected type '*fn ([]const u8) void', found 'void'
queue.append(.{ .priority = 100, .task = writeCustomer("Norbert Nudel") });
Maybe someone can show me a solution to put that function into a struct.
BR smf