I have this struct
pub const U = struct {
base_id: u32,
u0: ?T = null,
u1: ?T = null,
u2: ?T = null,
u3: ?T = null,
}
Based on input I want to check, if field is null, if it is, generate default, and in both cases return *T, is that even possible?
My current idea is something like this:
const un :*?T =
switch (u) {
0 => &entry.u0,
1 => &entry.u1,
2 => &entry.u2,
3 => &entry.u3,
};
if (un.*) |r| {
return &r;
} else {
}
But can not get it to compile.