Remove Iterator(Inner)._Inner

This commit is contained in:
Luuk Machielse 2025-12-08 09:05:51 +01:00
parent 0e6ad0cde9
commit 1a671a92ac

View file

@ -10,7 +10,7 @@ pub fn iter(comptime T: type) type {
test fromSlice {
const expectEqual = std.testing.expectEqual;
var it = iter(i32).fromSliceOwned(&.{ 1, 3, 2, 4 });
var it = iter(i32).fromSlice(&.{ 1, 3, 2, 4 });
try expectEqual(1, it.next());
try expectEqual(3, it.next());
@ -83,8 +83,6 @@ pub fn Iterator(comptime Inner: type) type {
.reset = @hasDecl(Inner, "reset"),
};
const _Inner = Inner;
const Self = @This();
pub fn next(self: *Self) ?Item {
@ -179,19 +177,19 @@ pub fn Iterator(comptime Inner: type) type {
}.some);
}
pub fn chain(self: Self, other: anytype) Iterator(adapters.Chain(Inner, @TypeOf(other)._Inner)) {
pub fn chain(self: Self, other: anytype) Iterator(adapters.Chain(Inner, @TypeOf(other.inner))) {
return .{ .inner = .{ .first = self.inner, .second = other.inner } };
}
pub fn zip(self: Self, other: anytype) Iterator(adapters.Zip(Inner, @TypeOf(other)._Inner)) {
pub fn zip(self: Self, other: anytype) Iterator(adapters.Zip(Inner, @TypeOf(other.inner))) {
return .{ .inner = .{ .a = self.inner, .b = other.inner } };
}
test zip {
const expectEqualDeep = std.testing.expectEqualDeep;
var it = iter(i32).fromSliceOwned(&.{ 1, 2, 3 })
.zip(iter(i32).fromSliceOwned(&.{ 4, 5, 6 }));
var it = iter(i32).fromSlice(&.{ 1, 2, 3 })
.zip(iter(i32).fromSlice(&.{ 4, 5, 6 }));
try expectEqualDeep(.{ 1, 4 }, it.next());
try expectEqualDeep(.{ 2, 5 }, it.next());