pub fn clone(m: *const Map, gpa: Allocator) Allocator.Error!Map 343
344
345
346
347
348
349
350
351 pub fn clone(m: *const Map, gpa: Allocator) Allocator.Error!Map {
var new: Map = .init(gpa);
errdefer new.deinit();
try new.array_hash_map.ensureUnusedCapacity(gpa, m.array_hash_map.count());
for (m.array_hash_map.keys(), m.array_hash_map.values()) |key, value| {
try new.put(key, value);
}
return new;
}
Returns a full copy of
emallocated withgpa, which is not necessarily the same allocator used to allocateem.