pub fn Interator3(comptime T: type) type { return struct { const Self = @This(); const Vector = @Vector(3, T); min: Vector, max: Vector, current: ?Vector, pub fn init(min_x: T, min_y: T, min_z: T, max_x: T, max_y: T, max_z: T) Self { const min: Vector = .{ min_x, min_y, min_z }; const max: Vector = .{ max_x, max_y, max_z }; return .{ .min = min, .max = max, .current = min, }; } pub fn next(self: *Self) ?[3]T { const current = self.current orelse return null; var next_current = current; next_current[0] = next_current[0] + 1; if (next_current[0] > self.max[0]) { next_current[0] = self.min[0]; next_current[1] = next_current[1] + 1; if (next_current[1] > self.max[1]) { next_current[1] = self.min[1]; next_current[2] = next_current[2] + 1; if (next_current[2] > self.max[2]) { self.current = null; return current; } } } self.current = next_current; return current; } }; }