mirror of
https://github.com/apple/swift-collections
synced 2026-11-25 04:37:48 +00:00
Add new span taking copying initializers to Rigid and UniqueArray
This commit is contained in:
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
|
||||
Reference in new issue
Block a user