I wrote this flexible iterator.
Is this switch in the next
method fully monomorphized?
Or do I need to inline something ?
pub fn MovIter(comptime T: type) type
{
return struct {
const Self = @This();
pub fn init(move: *const Move) Self {
if (!(T == LocatedLetter or T == Square)) {
@compileError("MovIter can only return LocatedLetter or Square");
}
return Self {
// init fields
};
}
pub fn next(self: *Self) ?T
{
switch (T)
{
LocatedLetter => return
return LocatedLetter {...}
},
Square =>
{
return square;
},
else => unreachable
}
}
};
}