Skip to content

Commit 2896266

Browse files
squeek502andrewrk
authored andcommitted
docs: Fix outdated doc comments about allocating 'at least' the requested size
The 'at least' behavior of the Allocator interface was removed in #13666, so anything that used reallocAtLeast or the .at_least Exact behavior could still have doc comments that reference no-longer-true behavior. Funnily enough, ArrayList is the only place that used this functionality (outside of allocator test cases), so its doc comments are the only things that need to be fixed. This was checked by resetting to deda6b5 and searching for all instances of `reallocAtLeast` and `.at_least` (one of which would need to be used to get the `.at_least` behavior)
1 parent e05c242 commit 2896266

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

lib/std/array_list.zig

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type {
6060
};
6161
}
6262

63-
/// Initialize with capacity to hold at least `num` elements.
64-
/// The resulting capacity is likely to be equal to `num`.
63+
/// Initialize with capacity to hold `num` elements.
64+
/// The resulting capacity will equal `num` exactly.
6565
/// Deinitialize with `deinit` or use `toOwnedSlice`.
6666
pub fn initCapacity(allocator: Allocator, num: usize) Allocator.Error!Self {
6767
var self = Self.init(allocator);
@@ -379,9 +379,9 @@ pub fn ArrayListAligned(comptime T: type, comptime alignment: ?u29) type {
379379
return self.ensureTotalCapacityPrecise(better_capacity);
380380
}
381381

382-
/// Modify the array so that it can hold at least `new_capacity` items.
383-
/// Like `ensureTotalCapacity`, but the resulting capacity is much more likely
384-
/// (but not guaranteed) to be equal to `new_capacity`.
382+
/// Modify the array so that it can hold `new_capacity` items.
383+
/// Like `ensureTotalCapacity`, but the resulting capacity is guaranteed
384+
/// to be equal to `new_capacity`.
385385
/// Invalidates pointers if additional memory is needed.
386386
pub fn ensureTotalCapacityPrecise(self: *Self, new_capacity: usize) Allocator.Error!void {
387387
if (@sizeOf(T) == 0) {
@@ -570,8 +570,8 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ
570570
return if (alignment) |a| ([:s]align(a) T) else [:s]T;
571571
}
572572

573-
/// Initialize with capacity to hold at least num elements.
574-
/// The resulting capacity is likely to be equal to `num`.
573+
/// Initialize with capacity to hold `num` elements.
574+
/// The resulting capacity will equal `num` exactly.
575575
/// Deinitialize with `deinit` or use `toOwnedSlice`.
576576
pub fn initCapacity(allocator: Allocator, num: usize) Allocator.Error!Self {
577577
var self = Self{};
@@ -885,9 +885,9 @@ pub fn ArrayListAlignedUnmanaged(comptime T: type, comptime alignment: ?u29) typ
885885
return self.ensureTotalCapacityPrecise(allocator, better_capacity);
886886
}
887887

888-
/// Modify the array so that it can hold at least `new_capacity` items.
889-
/// Like `ensureTotalCapacity`, but the resulting capacity is much more likely
890-
/// (but not guaranteed) to be equal to `new_capacity`.
888+
/// Modify the array so that it can hold `new_capacity` items.
889+
/// Like `ensureTotalCapacity`, but the resulting capacity is guaranteed
890+
/// to be equal to `new_capacity`.
891891
/// Invalidates pointers if additional memory is needed.
892892
pub fn ensureTotalCapacityPrecise(self: *Self, allocator: Allocator, new_capacity: usize) Allocator.Error!void {
893893
if (@sizeOf(T) == 0) {

0 commit comments

Comments
 (0)