From 05890a12f532ba9d58904a14381ec174b9efe473 Mon Sep 17 00:00:00 2001 From: Mikael Berthe Date: Sun, 11 Dec 2022 15:39:25 +0100 Subject: [PATCH] std: Update ArrayList documentation Calling `deinit` might still be required after using `toOwnedSlice` now. --- lib/std/array_list.zig | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/std/array_list.zig b/lib/std/array_list.zig index e8675fde61..759a8f6a6c 100644 --- a/lib/std/array_list.zig +++ b/lib/std/array_list.zig @@ -51,7 +51,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { return if (alignment) |a| ([:s]align(a) T) else [:s]T; } - /// Deinitialize with `deinit` or use `toOwnedSlice`. + /// Deinitialize with `deinit`. pub fn init(allocator: Allocator) Self { return Self{ .items = &[_]T{}, @@ -62,7 +62,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { /// Initialize with capacity to hold at least `num` elements. /// The resulting capacity is likely to be equal to `num`. - /// Deinitialize with `deinit` or use `toOwnedSlice`. + /// Deinitialize with `deinit`. pub fn initCapacity(allocator: Allocator, num: usize) Allocator.Error!Self { var self = Self.init(allocator); try self.ensureTotalCapacityPrecise(num); @@ -78,7 +78,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { /// ArrayList takes ownership of the passed in slice. The slice must have been /// allocated with `allocator`. - /// Deinitialize with `deinit` or use `toOwnedSlice`. + /// Deinitialize with `deinit`. pub fn fromOwnedSlice(allocator: Allocator, slice: Slice) Self { return Self{ .items = slice, @@ -475,7 +475,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type { /// An ArrayList, but the allocator is passed as a parameter to the relevant functions /// rather than stored in the struct itself. The same allocator **must** be used throughout /// the entire lifetime of an ArrayListUnmanaged. Initialize directly or with -/// `initCapacity`, and deinitialize with `deinit` or use `toOwnedSlice`. +/// `initCapacity`, and deinitialize with `deinit`. pub fn ArrayListUnmanaged(comptime T: type) type { return ArrayListAlignedUnmanaged(T, null); } @@ -483,7 +483,7 @@ pub fn ArrayListUnmanaged(comptime T: type) type { /// An ArrayListAligned, but the allocator is passed as a parameter to the relevant /// functions rather than stored in the struct itself. The same allocator **must** /// be used throughout the entire lifetime of an ArrayListAlignedUnmanaged. -/// Initialize directly or with `initCapacity`, and deinitialize with `deinit` or use `toOwnedSlice`. +/// Initialize directly or with `initCapacity`, and deinitialize with `deinit`. pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) type { if (alignment) |a| { if (a == @alignOf(T)) { @@ -514,7 +514,7 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ /// Initialize with capacity to hold at least num elements. /// The resulting capacity is likely to be equal to `num`. - /// Deinitialize with `deinit` or use `toOwnedSlice`. + /// Deinitialize with `deinit`. pub fn initCapacity(allocator: Allocator, num: usize) Allocator.Error!Self { var self = Self{}; try self.ensureTotalCapacityPrecise(allocator, num);