Add new span taking copying initializers to Rigid and UniqueArray

This commit is contained in:
Alejandro Alonso committed 2026-02-12 11:01:30 -08:00
1 parent 324439ab79
commit 3bf8de6e2b
4 files changed
+80

No files matched your search

@@ -139,6 +139,23 @@ extension UniqueArray /*where Element: Copyable*/ {
}
#endif
/// Creates a new array with the specified capacity, holding a copy
/// of the contents of the given span.
///
/// - Parameters:
/// - capacity: The storage capacity of the new array, or nil to allocate
/// just enough capacity to store the contents of the span.
/// - span: The span whose contents to copy into the new array.
/// The span must not contain more than `capacity` elements.
@_alwaysEmitIntoClient
@inline(__always)
public init(
capacity: Int? = nil,
copying span: Span<Element>
) {
self.init(capacity: capacity ?? span.count)
self.append(copying: span)
}
}
#endif