diff --git a/Sources/NIO/ByteBuffer-core.swift b/Sources/NIO/ByteBuffer-core.swift index 6d74396ba5..5071cf9047 100644 --- a/Sources/NIO/ByteBuffer-core.swift +++ b/Sources/NIO/ByteBuffer-core.swift @@ -624,6 +624,7 @@ extension ByteBuffer: CustomStringConvertible { /// A `Collection` that is contiguously layed out in memory and can therefore be duplicated using `memcpy`. public protocol ContiguousCollection: Collection { + @_inlineable func withUnsafeBytes(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R } diff --git a/Sources/NIOFoundationCompat/ByteBuffer-foundation.swift b/Sources/NIOFoundationCompat/ByteBuffer-foundation.swift index 084ffc7ca8..6f35f300fe 100644 --- a/Sources/NIOFoundationCompat/ByteBuffer-foundation.swift +++ b/Sources/NIOFoundationCompat/ByteBuffer-foundation.swift @@ -30,6 +30,7 @@ import struct Foundation.Data */ extension Data: ContiguousCollection { + @_inlineable public func withUnsafeBytes(_ body: (UnsafeRawBufferPointer) throws -> R) rethrows -> R { return try self.withUnsafeBytes { (ptr: UnsafePointer) -> R in try body(UnsafeRawBufferPointer(start: ptr, count: self.count))