Include notes about index mutation in span(after/before:)

The indexes passed to span(after:) and friends on UniqueArray
and RigidArray are modified before return. This adds notes
about the updated values to the method documentation, along
with a few other minor formatting changes (dropping smart
quotes, single-sentence abstracts).
This commit is contained in:
Nate Cook authored and Karoy Lorentey committed 2026-03-02 16:38:48 -08:00
1 parent aa337b4caf
commit 54ca53612f
28 files changed
+143 -109

No files matched your search

@@ -130,6 +130,7 @@ extension UniqueArray where Element: ~Copyable {
extension UniqueArray where Element: ~Copyable {
/// Arbitrarily edit the storage underlying this array by invoking a
/// user-supplied closure with a mutable `OutputSpan` view over it.
///
/// This method calls its function argument at most once, allowing it to
/// arbitrarily modify the contents of the output span it is given.
/// The argument is free to add, remove or reorder any items; however,
@@ -158,10 +159,14 @@ extension UniqueArray where Element: ~Copyable {
@available(SwiftStdlib 5.0, *)
extension UniqueArray where Element: ~Copyable {
/// Return a borrowing span over the maximal storage chunk following the
/// specified position in the array. The span provides direct read-only access
/// to all array elements in the range `index ..< count`.
/// specified position in the array.
///
/// The returned span provides direct read-only access to all array elements
/// in the range `index ..< count`.
///
/// - Parameter index: A valid index in the array, including the end index.
/// When `span(after:)` returns, `index` is equal to the array's
/// `endIndex`.
///
/// - Complexity: O(1)
@inlinable
@@ -171,10 +176,14 @@ extension UniqueArray where Element: ~Copyable {
}
/// Return a borrowing span over the maximal storage chunk preceding the
/// specified position in the array. The span provides direct read-only access
/// to all array elements in the range `0 ..< index`.
/// specified position in the array.
///
/// The returned span provides direct read-only access to all array elements
/// in the range `0 ..< index`.
///
/// - Parameter index: A valid index in the array, including the end index.
/// When `span(before:)` returns, `index` is equal to the array's
/// `startIndex`.
///
/// - Complexity: O(1)
@inlinable
@@ -187,10 +196,14 @@ extension UniqueArray where Element: ~Copyable {
@available(SwiftStdlib 5.0, *)
extension UniqueArray where Element: ~Copyable {
/// Return a mutable span over the maximal storage chunk following the
/// specified position in the array. The span provides direct mutating access
/// to all array elements in the range `index ..< count`.
/// specified position in the array.
///
/// The returned span provides direct mutating access to all array elements
/// in the range `index ..< count`.
///
/// - Parameter index: A valid index in the array, including the end index.
/// When `mutableSpan(after:)` returns, `index` is equal to the array's
/// `endIndex`.
///
/// - Complexity: O(1)
@_lifetime(&self)
@@ -201,10 +214,14 @@ extension UniqueArray where Element: ~Copyable {
}
/// Return a mutable span over the maximal storage chunk preceding the specified
/// position in the array. The span provides direct mutating access to all
/// array elements in the range `0 ..< index`.
/// position in the array.
///
/// The returned span provides direct mutating access to all array elements
/// in the range `0 ..< index`.
///
/// - Parameter index: A valid index in the array, including the end index.
/// When `mutableSpan(before:)` returns, `index` is equal to the array's
/// `startIndex`.
///
/// - Complexity: O(1)
@_lifetime(&self)
@@ -291,7 +308,7 @@ extension UniqueArray {
public func clone() -> Self {
UniqueArray(consuming: _storage.clone())
}
/// Copy the contents of this array into a newly allocated unique array
/// instance with the specified capacity.
///