WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 6ab735c

Browse files
committed
Generalize withContiguousStorageIfAvailable as well
1 parent 248dc87 commit 6ab735c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Sources/FoundationEssentials/Data/Data.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,11 @@ public struct Data : RandomAccessCollection, MutableCollection, RangeReplaceable
476476
}
477477

478478
@_alwaysEmitIntoClient
479-
public func withContiguousStorageIfAvailable<ResultType>(_ body: (_ buffer: UnsafeBufferPointer<UInt8>) throws -> ResultType) rethrows -> ResultType? {
480-
return try _representation.withUnsafeBytes {
481-
return try $0.withMemoryRebound(to: UInt8.self, body)
479+
public func withContiguousStorageIfAvailable<E, ResultType: ~Copyable>(
480+
_ body: (_ buffer: UnsafeBufferPointer<UInt8>) throws(E) -> ResultType
481+
) throws(E) -> ResultType? {
482+
try _representation.withUnsafeBytes { bytes throws(E) in
483+
try bytes.withMemoryRebound(to: UInt8.self, body)
482484
}
483485
}
484486

0 commit comments

Comments
 (0)