Can we simulate rust like traits in Zig (to add methods to a struct)?

Yeah I often had the same problem in C++ libraries.

Ok different proposal: readonly struct members… e.g. capacity can be read from everywhere, but only written from within the ArrayList implementation functions.

It always goes back to the idea that’s rolling around in the back of my head for like a decade now that programming languages should have fine-grained filesystem-like access rules instead of the overly simplistic public/private/const/var model.

7 Likes