mirror of
https://codeberg.org/kaasboteram/zig-iterating.git
synced 2025-12-15 09:43:14 +01:00
Remove Iterator(Inner)._Inner
This commit is contained in:
parent
0e6ad0cde9
commit
1a671a92ac
1 changed files with 5 additions and 7 deletions
12
src/root.zig
12
src/root.zig
|
|
@ -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());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue