mirror of
https://codeberg.org/kaasboteram/zig-iterating.git
synced 2025-12-15 09:43:14 +01:00
remove Iterator(Inner).collectInto
This commit is contained in:
parent
b9098aea59
commit
1e9bd2454e
1 changed files with 3 additions and 7 deletions
10
src/root.zig
10
src/root.zig
|
|
@ -200,16 +200,12 @@ pub fn Iterator(comptime Inner: type) type {
|
|||
var list: std.ArrayList(Item) = try .initCapacity(allocator, self.sizeHint());
|
||||
errdefer list.deinit(allocator);
|
||||
|
||||
try self.collectInto(&list, allocator);
|
||||
while (self.next()) |item| {
|
||||
try list.append(allocator, item);
|
||||
}
|
||||
|
||||
return try list.toOwnedSlice(allocator);
|
||||
}
|
||||
|
||||
pub fn collectInto(self: *Self, list: *std.ArrayList(Item), allocator: std.mem.Allocator) !void {
|
||||
while (self.next()) |val| {
|
||||
try list.append(allocator, val);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue