Is there way to implement a generic get_attribute

Something like:

const value = .{ .foo = "foo string"};
const attr_value = get_attribute(value,  "foo");

I think @field(value, "foo") would work?

https://ziglang.org/documentation/master/#field

3 Likes