Skip to content

Commit 82ae264

Browse files
committed
[stdlib] convert withUnsafeMutablePointer() to typed throws
1 parent 0cc0590 commit 82ae264

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

stdlib/public/core/LifetimeManager.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,20 @@ public func _fixLifetime<T>(_ x: T) {
7474
/// execution.
7575
/// - Returns: The return value, if any, of the `body` closure.
7676
@inlinable
77-
public func withUnsafeMutablePointer<T, Result>(
77+
@_alwaysEmitIntoClient
78+
public func withUnsafeMutablePointer<T, E: Error, Result>(
79+
to value: inout T,
80+
_ body: (UnsafeMutablePointer<T>) throws(E) -> Result
81+
) throws(E) -> Result {
82+
try body(UnsafeMutablePointer<T>(Builtin.addressof(&value)))
83+
}
84+
85+
@_silgen_name("$ss24withUnsafeMutablePointer2to_q_xz_q_SpyxGKXEtKr0_lF")
86+
@usableFromInline
87+
func __abi_se0413_withUnsafeMutablePointer<T, Result>(
7888
to value: inout T,
7989
_ body: (UnsafeMutablePointer<T>) throws -> Result
80-
) rethrows -> Result
81-
{
90+
) throws -> Result {
8291
return try body(UnsafeMutablePointer<T>(Builtin.addressof(&value)))
8392
}
8493

0 commit comments

Comments
 (0)