Skip to content

Commit 3f4990d

Browse files
authored
Merge pull request #21611 from weissi/jw-make-urbp-contiguous
conform Unsafe(Mutable)RawBufferPointer conform to _HasContiguousBytes
2 parents 3fb401c + f87ffd2 commit 3f4990d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

stdlib/public/core/ContiguouslyStored.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,22 @@ extension UnsafeMutableBufferPointer: _HasContiguousBytes {
5757
return try body(UnsafeRawBufferPointer(start: ptr, count: len))
5858
}
5959
}
60+
extension UnsafeRawBufferPointer: _HasContiguousBytes {
61+
@inlinable @inline(__always)
62+
func withUnsafeBytes<R>(
63+
_ body: (UnsafeRawBufferPointer) throws -> R
64+
) rethrows -> R {
65+
return try body(self)
66+
}
67+
}
68+
extension UnsafeMutableRawBufferPointer: _HasContiguousBytes {
69+
@inlinable @inline(__always)
70+
func withUnsafeBytes<R>(
71+
_ body: (UnsafeRawBufferPointer) throws -> R
72+
) rethrows -> R {
73+
return try body(UnsafeRawBufferPointer(self))
74+
}
75+
}
6076
extension String: _HasContiguousBytes {
6177
@inlinable
6278
internal var _providesContiguousBytesNoCopy: Bool {

0 commit comments

Comments
 (0)