@@ -1288,10 +1288,23 @@ public func _withUnprotectedUnsafeBytes<T, Result>(
1288
1288
/// `withUnsafeMutableBytes(of:_:)` instead.
1289
1289
/// - Returns: The return value, if any, of the `body` closure.
1290
1290
@inlinable
1291
- public func withUnsafeBytes< T, Result> (
1291
+ @_alwaysEmitIntoClient
1292
+ public func withUnsafeBytes< T, Result, E: Error > (
1293
+ of value: T ,
1294
+ _ body: ( UnsafeRawBufferPointer ) throws ( E ) -> Result
1295
+ ) throws ( E) -> Result {
1296
+ let addr = UnsafeRawPointer ( Builtin . addressOfBorrow ( value) )
1297
+ return try body ( . init( start: addr, count: MemoryLayout< T> . size) )
1298
+ }
1299
+
1300
+ /// ABI: Historical withUnsafeBytes(of:_:) rethrows,
1301
+ /// expressed as "throws", which is ABI-compatible with "rethrows".
1302
+ @_silgen_name ( " $ss15withUnsafeBytes2of_q_x_q_SWKXEtKr0_lF " )
1303
+ @usableFromInline
1304
+ func __abi_se0413_withUnsafeBytes< T, Result> (
1292
1305
of value: T ,
1293
1306
_ body: ( UnsafeRawBufferPointer ) throws -> Result
1294
- ) rethrows -> Result {
1307
+ ) throws -> Result {
1295
1308
let addr = UnsafeRawPointer ( Builtin . addressOfBorrow ( value) )
1296
1309
let buffer = UnsafeRawBufferPointer ( start: addr, count: MemoryLayout< T> . size)
1297
1310
return try body ( buffer)
@@ -1303,10 +1316,10 @@ public func withUnsafeBytes<T, Result>(
1303
1316
/// This function is similar to `withUnsafeBytes`, except that it
1304
1317
/// doesn't trigger stack protection for the pointer.
1305
1318
@_alwaysEmitIntoClient
1306
- public func _withUnprotectedUnsafeBytes< T, Result> (
1319
+ public func _withUnprotectedUnsafeBytes< T, Result, E : Error > (
1307
1320
of value: T ,
1308
- _ body: ( UnsafeRawBufferPointer ) throws -> Result
1309
- ) rethrows -> Result {
1321
+ _ body: ( UnsafeRawBufferPointer ) throws ( E ) -> Result
1322
+ ) throws ( E ) -> Result {
1310
1323
#if $BuiltinUnprotectedAddressOf
1311
1324
let addr = UnsafeRawPointer ( Builtin . unprotectedAddressOfBorrow ( value) )
1312
1325
#else
0 commit comments