SE-0527 has been Accepted in Principle, but we would like to extend a focused review period for one API that is mostly unprecedented in the standard library and packages, and which did not receive much attention on the original thread:
The API in question appears below:
/// Grow or shrink the capacity of a unique array instance without discarding
/// its contents.
///
/// This operation replaces the array's storage buffer with a newly allocated
/// buffer of the specified capacity, moving all existing elements
/// to its new storage. The old storage is then deallocated.
///
/// - Parameter newCapacity: The desired new capacity. newCapacity must be
/// greater than or equal to the current count.
///
/// - Complexity: O(count)
public mutating func reallocate(capacity newCapacity: Int)
In the original review thread, one commenter suggested naming this resize(capacity:) instead of reallocate(capacity:). The proposal authors were willing to take this name, but some members of the LSG feel that it suggests an operation that changes the count rather than capacity and prefer the original name ("it says what it does").
I would also like to pin down the use cases and semantics of this operation a bit more precisely:
- how necessary is it to have this either grow or shrink vs shrink-only (like e.g. Rust's
shrink_to_fit)? - if it can grow, should it permit a growth factor to prevent accidentally-quadratic behavior, or reallocate to precisely the given capacity?
- how much use do people have for shrinking to a specified capacity, instead of simply always shrinking to
count?
This focused re-review begins now and runs through June 2, 2026.
Reviews are an important part of the Swift evolution process. All review feedback should be either on this forum thread or, if you would like to keep your feedback private, directly to the review manager via the forum messaging feature. When contacting the review manager directly, please keep the proposal link at the top of the message.
What goes into a review?
The goal of the review process is to improve the proposal under review through constructive criticism and, eventually, determine the direction of Swift. When writing your review, here are some questions you might want to answer in your review:
- What is your evaluation of the proposal?
- Is the problem being addressed significant enough to warrant a change to Swift?
- Does this proposal fit well with the feel and direction of Swift?
- If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?
- How much effort did you put into your review? A glance, a quick reading, or an in-depth study?
More information about the Swift evolution process is available here.
Thank you,
Steve Canon
Review Manager