Renamed iter to Iter

This commit is contained in:
Luuk Machielse 2025-10-10 17:10:05 +02:00
parent a5d2efdd10
commit 4c80f07498
2 changed files with 11 additions and 11 deletions

View file

@ -1,5 +1,5 @@
const std = @import("std"); const std = @import("std");
const iter = @import("iterating").iter; const iter = @import("iterating").Iter;
pub fn main() !void { pub fn main() !void {
const arith = struct { const arith = struct {

View file

@ -1,6 +1,6 @@
const std = @import("std"); const std = @import("std");
pub fn iter(comptime T: type) type { pub fn Iter(comptime T: type) type {
return struct { return struct {
pub fn fromSlice(slice: anytype) Iterator( pub fn fromSlice(slice: anytype) Iterator(
if (@typeInfo(@TypeOf(slice)).pointer.is_const) SliceIterConst(T) else SliceIter(T), if (@typeInfo(@TypeOf(slice)).pointer.is_const) SliceIterConst(T) else SliceIter(T),
@ -22,7 +22,7 @@ pub fn iter(comptime T: type) type {
}; };
} }
test iter { test Iter {
const testing = @import("std").testing; const testing = @import("std").testing;
const gpa = testing.allocator; const gpa = testing.allocator;
@ -34,12 +34,12 @@ test iter {
} }
}; };
const items = try iter(i32) const items = try Iter(i32)
.once(-100) .once(-100)
.chain(iter(i32) .chain(Iter(i32)
.rangeInclusive(1, 100) .rangeInclusive(1, 100)
.filter(arith.is_square) .filter(arith.is_square)
.chain(iter(i32) .chain(Iter(i32)
.range(0, 10))) .range(0, 10)))
.toOwnedSlice(gpa); .toOwnedSlice(gpa);
@ -147,12 +147,12 @@ pub fn Iterator(comptime Inner: type) type {
}; };
} }
fn Clean(comptime Iter: type) type { fn Clean(comptime It: type) type {
if (@hasDecl(Iter, "_Inner")) { if (@hasDecl(It, "_Inner")) {
if (Iterator(Iter._Inner) == Iter) return Iter._Inner; if (Iterator(It._Inner) == It) return It._Inner;
} }
return Iter; return It;
} }
pub const adapters = struct { pub const adapters = struct {
@ -350,7 +350,7 @@ pub fn SliceIterConst(comptime T: type) type {
test "slices" { test "slices" {
const slice: []const i32 = &[_]i32{ -2, -1, 0, 1, 2 }; const slice: []const i32 = &[_]i32{ -2, -1, 0, 1, 2 };
var it = iter(i32).fromSlice(slice).enumerate(); var it = Iter(i32).fromSlice(slice).enumerate();
while (it.next()) |pair| { while (it.next()) |pair| {
const i, const val = pair; const i, const val = pair;