Skip to content

Commit fcf1d5e

Browse files
committed
Change the signature for DispatchData.enumerateBytes() to match that of Data.enumerateBytes() for Swift 4.2 and obsolete the old version.
rdar://problem/40775762
1 parent ba3933d commit fcf1d5e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/swift/Data.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,22 @@ public struct DispatchData : RandomAccessCollection {
117117
return try body(contentPtr)
118118
}
119119

120+
@available(swift 4.2)
121+
public func enumerateBytes(
122+
_ block: (_ buffer: UnsafeBufferPointer<UInt8>, _ byteIndex: Int, _ stop: inout Bool) -> Void)
123+
{
124+
enumerateBytesCommon(block)
125+
}
126+
127+
@available(swift, obsoleted: 4.2, renamed: "enumerateBytes(_:)")
120128
public func enumerateBytes(
121129
block: (_ buffer: UnsafeBufferPointer<UInt8>, _ byteIndex: Int, _ stop: inout Bool) -> Void)
130+
{
131+
enumerateBytesCommon(block)
132+
}
133+
134+
private func enumerateBytesCommon(
135+
_ block: (_ buffer: UnsafeBufferPointer<UInt8>, _ byteIndex: Int, _ stop: inout Bool) -> Void)
122136
{
123137
// we know that capturing block in the closure being created/passed to dispatch_data_apply
124138
// does not cause block to escape because dispatch_data_apply does not allow its

0 commit comments

Comments
 (0)