aboutsummaryrefslogtreecommitdiff
path: root/lib/std/buf_set.zig
diff options
context:
space:
mode:
Diffstat (limited to 'lib/std/buf_set.zig')
-rw-r--r--lib/std/buf_set.zig15
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/std/buf_set.zig b/lib/std/buf_set.zig
index fc858f220c..9d6d7ed1e6 100644
--- a/lib/std/buf_set.zig
+++ b/lib/std/buf_set.zig
@@ -78,7 +78,7 @@ pub const BufSet = struct {
) Allocator.Error!BufSet {
var cloned_hashmap = try self.hash_map.cloneWithAllocator(new_allocator);
var cloned = BufSet{ .hash_map = cloned_hashmap };
- var it = self.hash_map.keyIterator();
+ var it = cloned.hash_map.keyIterator();
while (it.next()) |key_ptr| {
key_ptr.* = try cloned.copy(key_ptr.*);
}
@@ -132,3 +132,16 @@ test "BufSet clone" {
original.cloneWithAllocator(testing.failing_allocator),
);
}
+
+test "BufSet.clone with arena" {
+ var allocator = std.testing.allocator;
+ var arena = std.heap.ArenaAllocator.init(allocator);
+ defer arena.deinit();
+
+ var buf = BufSet.init(allocator);
+ defer buf.deinit();
+ try buf.insert("member1");
+ try buf.insert("member2");
+
+ _ = try buf.cloneWithAllocator(arena.allocator());
+}