Hi,
I would like to somehow express something like this in Zig, but I'm struggling:
const y = switch(c) {
inline if (doesSatisfyArbitraryCondition(c)) => |x| comptime f(x),
else => somethingElseNotInlined,
};
is there some way to express this idea?
I have tried, for example:
pub fn f(x:u8) u8 {
std.debug.assert(x>3 and x<6);
return x;
}
pub fn g(x:u8) u8 {
const r = if(x>3 and x<6) 0 else switch(x){
inline else => |y| comptime f(y),
};
return r;
}
but this does not work as it tries to inline everything in the switch, even though not all branches are going to be reachable.