mirror of
https://codeberg.org/kaasboteram/zig-iterating.git
synced 2025-12-15 09:43:14 +01:00
Renamed many variables/paramaters called gpa to allocator
This commit is contained in:
parent
a440d40797
commit
075b246858
1 changed files with 9 additions and 9 deletions
18
src/root.zig
18
src/root.zig
|
|
@ -37,7 +37,7 @@ pub fn Iter(comptime T: type) type {
|
|||
test Iter {
|
||||
const testing = @import("std").testing;
|
||||
|
||||
const gpa = testing.allocator;
|
||||
const allocator = testing.allocator;
|
||||
|
||||
const arith = struct {
|
||||
fn is_square(x: i32) bool {
|
||||
|
|
@ -55,9 +55,9 @@ test Iter {
|
|||
.chain(Iter(i32)
|
||||
.range(0, 10)),
|
||||
)
|
||||
.toOwnedSlice(gpa);
|
||||
.toOwnedSlice(allocator);
|
||||
|
||||
defer gpa.free(items);
|
||||
defer allocator.free(items);
|
||||
|
||||
try testing.expectEqualSlices(
|
||||
i32,
|
||||
|
|
@ -173,19 +173,19 @@ pub fn Iterator(comptime Inner: type) type {
|
|||
try testing.expectEqualDeep(struct { i32, i32 }{ 10, 20 }, it.next().?);
|
||||
}
|
||||
|
||||
pub fn toOwnedSlice(self: Self, gpa: std.mem.Allocator) ![]const Item {
|
||||
pub fn toOwnedSlice(self: Self, allocator: std.mem.Allocator) ![]const Item {
|
||||
var list: std.ArrayList(Item) = .empty;
|
||||
errdefer list.deinit(gpa);
|
||||
errdefer list.deinit(allocator);
|
||||
|
||||
try self.collectInto(&list, gpa);
|
||||
try self.collectInto(&list, allocator);
|
||||
|
||||
return try list.toOwnedSlice(gpa);
|
||||
return try list.toOwnedSlice(allocator);
|
||||
}
|
||||
|
||||
pub fn collectInto(self: Self, list: *std.ArrayList(Item), gpa: std.mem.Allocator) !void {
|
||||
pub fn collectInto(self: Self, list: *std.ArrayList(Item), allocator: std.mem.Allocator) !void {
|
||||
var mutSelf = self;
|
||||
while (mutSelf.next()) |val| {
|
||||
try list.append(gpa, val);
|
||||
try list.append(allocator, val);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue