Zig doesn't have attributes, but you could just create a thin wrapper struct over an inner type and use setter functions that throw errors on invalid values. Personally I prefer this over attributes because it forces you to handle possible error states from the callers of the setters, instead of relying on you remembering to call `validate` on your types.
8 comments
[ 0.25 ms ] story [ 9.0 ms ] threadFrom what I can see the example started from C++, and then comparing how each language would look building it in userland instead.