authorgravatar for mikael@lilotux.netMikael Berthe <mikael@lilotux.net> 2022-12-11 15:39:25+01:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-12-11 17:42:26+02:00
log05890a12f532ba9d58904a14381ec174b9efe473
treedb097170ebee0efa39ed427b4d70c49fe19bc80b
parent6f77bef4dc3fea3fcec9d805322009c979de9a88

std: Update ArrayList documentation

Calling `deinit` might still be required after using `toOwnedSlice` now.

1 files changed, 6 insertions(+), 6 deletions(-)

lib/std/array_list.zig+6-6
......@@ -51,7 +51,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type {
5151 return if (alignment) |a| ([:s]align(a) T) else [:s]T;
5252 }
5353
54 /// Deinitialize with `deinit` or use `toOwnedSlice`.
54 /// Deinitialize with `deinit`.
5555 pub fn init(allocator: Allocator) Self {
5656 return Self{
5757 .items = &[_]T{},
......@@ -62,7 +62,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type {
6262
6363 /// Initialize with capacity to hold at least `num` elements.
6464 /// The resulting capacity is likely to be equal to `num`.
65 /// Deinitialize with `deinit` or use `toOwnedSlice`.
65 /// Deinitialize with `deinit`.
6666 pub fn initCapacity(allocator: Allocator, num: usize) Allocator.Error!Self {
6767 var self = Self.init(allocator);
6868 try self.ensureTotalCapacityPrecise(num);
......@@ -78,7 +78,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type {
7878
7979 /// ArrayList takes ownership of the passed in slice. The slice must have been
8080 /// allocated with `allocator`.
81 /// Deinitialize with `deinit` or use `toOwnedSlice`.
81 /// Deinitialize with `deinit`.
8282 pub fn fromOwnedSlice(allocator: Allocator, slice: Slice) Self {
8383 return Self{
8484 .items = slice,
......@@ -475,7 +475,7 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type {
475475/// An ArrayList, but the allocator is passed as a parameter to the relevant functions
476476/// rather than stored in the struct itself. The same allocator **must** be used throughout
477477/// the entire lifetime of an ArrayListUnmanaged. Initialize directly or with
478/// `initCapacity`, and deinitialize with `deinit` or use `toOwnedSlice`.
478/// `initCapacity`, and deinitialize with `deinit`.
479479pub fn ArrayListUnmanaged(comptime T: type) type {
480480 return ArrayListAlignedUnmanaged(T, null);
481481}
......@@ -483,7 +483,7 @@ pub fn ArrayListUnmanaged(comptime T: type) type {
483483/// An ArrayListAligned, but the allocator is passed as a parameter to the relevant
484484/// functions rather than stored in the struct itself. The same allocator **must**
485485/// be used throughout the entire lifetime of an ArrayListAlignedUnmanaged.
486/// Initialize directly or with `initCapacity`, and deinitialize with `deinit` or use `toOwnedSlice`.
486/// Initialize directly or with `initCapacity`, and deinitialize with `deinit`.
487487pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) type {
488488 if (alignment) |a| {
489489 if (a == @alignOf(T)) {
......@@ -514,7 +514,7 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ
514514
515515 /// Initialize with capacity to hold at least num elements.
516516 /// The resulting capacity is likely to be equal to `num`.
517 /// Deinitialize with `deinit` or use `toOwnedSlice`.
517 /// Deinitialize with `deinit`.
518518 pub fn initCapacity(allocator: Allocator, num: usize) Allocator.Error!Self {
519519 var self = Self{};
520520 try self.ensureTotalCapacityPrecise(allocator, num);