Skip to content

Commit 6512840

Browse files
committed
[stdlib] update copyBytes with primary associated type
1 parent 83c18de commit 6512840

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

stdlib/public/core/UnsafeBufferPointerSlice.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ extension Slice where Base == UnsafeMutableRawBufferPointer {
2626
/// be less than or equal to this buffer slice's `count`.
2727
@inlinable
2828
@_alwaysEmitIntoClient
29-
public func copyBytes<C: Collection>(
30-
from source: C
31-
) where C.Element == UInt8 {
29+
public func copyBytes(from source: some Collection<UInt8>) {
3230
let buffer = Base(rebasing: self)
3331
buffer.copyBytes(from: source)
3432
}

stdlib/public/core/UnsafeRawBufferPointer.swift.gyb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,16 +534,15 @@ extension Unsafe${Mutable}RawBufferPointer {
534534
/// - Parameter source: A collection of `UInt8` elements. `source.count` must
535535
/// be less than or equal to this buffer's `count`.
536536
@inlinable
537-
public func copyBytes<C: Collection>(from source: C
538-
) where C.Element == UInt8 {
537+
public func copyBytes(from source: some Collection<UInt8>) {
539538
_debugPrecondition(source.count <= self.count,
540539
"${Self}.copyBytes source has too many elements")
541540
guard let position = _position else {
542541
return
543542
}
544543

545544
if source.withContiguousStorageIfAvailable({
546-
(buffer: UnsafeBufferPointer<C.Element>) -> Void in
545+
(buffer: UnsafeBufferPointer<UInt8>) -> Void in
547546
if let base = buffer.baseAddress {
548547
position.copyMemory(from: base, byteCount: buffer.count)
549548
}

0 commit comments

Comments
 (0)