From 997600ac6f8683a9c0935143dd345602bd4a8889 Mon Sep 17 00:00:00 2001 From: John Schmidt Date: Thu, 16 Dec 2021 10:55:35 +0100 Subject: [PATCH] Preserve alignment when cloning --- lib/std/array_list.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/std/array_list.zig b/lib/std/array_list.zig index b63225a930..76e73a49b5 100644 --- a/lib/std/array_list.zig +++ b/lib/std/array_list.zig @@ -110,7 +110,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { /// Creates a copy of this ArrayList, using the same allocator. pub fn clone(self: *Self) !Self { - var cloned = try ArrayList(T).initCapacity(self.allocator, self.capacity); + var cloned = try Self.initCapacity(self.allocator, self.capacity); cloned.appendSliceAssumeCapacity(self.items); return cloned; } @@ -498,7 +498,7 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ /// Creates a copy of this ArrayList. pub fn clone(self: *Self, allocator: Allocator) !Self { - var cloned = try ArrayListUnmanaged(T).initCapacity(allocator, self.capacity); + var cloned = try Self.initCapacity(allocator, self.capacity); cloned.appendSliceAssumeCapacity(self.items); return cloned; }