How can I implement a map in Zig (v0.11.0) that associates i32 values with function references?
In C++, I would use std::function
for this purpose, but I'm unable to find an equivalent in Zig. I've thoroughly searched the documentation and various online forums, but I couldn't find any information.
I'm hoping someone with great Zig experience could provide me with a solution on how to achieve this.
Any assistance would be greatly appreciated (I'm very sorry for my bad English, it's my fourth language).
Use function pointers or function bodies.
You can also use
std.ArrayHashMap
to avoid implementing the map yourself. For example: