Skip to content

Commit ee58cba

Browse files
authored
Transferring Result (#2404)
1 parent f80ad1e commit ee58cba

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

proposals/0433-mutex.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ extension Mutex where State: ~Copyable {
124124
/// - Warning: Recursive calls to `withLock` within the
125125
/// closure parameter has behavior that is platform dependent.
126126
/// Some platforms may choose to panic the process, deadlock,
127-
/// or leave this behavior unspecified.
127+
/// or leave this behavior unspecified. This will never
128+
/// reacquire the lock however.
128129
///
129130
/// - Parameter body: A closure with a parameter of `State`
130131
/// that has exclusive access to the value being stored within
@@ -133,9 +134,9 @@ extension Mutex where State: ~Copyable {
133134
/// acquired the lock.
134135
///
135136
/// - Returns: The return value, if any, of the `body` closure parameter.
136-
public borrowing func withLock<Result: ~Copyable & Sendable, E: Error>(
137-
_ body: (transferring inout State) throws(E) -> Result
138-
) throws(E) -> Result
137+
public borrowing func withLock<Result: ~Copyable, E: Error>(
138+
_ body: (transferring inout State) throws(E) -> transferring Result
139+
) throws(E) -> transferring Result
139140

140141
/// Attempts to acquire the lock and then calls the given closure if
141142
/// successful.
@@ -158,7 +159,8 @@ extension Mutex where State: ~Copyable {
158159
/// - Warning: Recursive calls to `withLockIfAvailable` within the
159160
/// closure parameter has behavior that is platform dependent.
160161
/// Some platforms may choose to panic the process, deadlock,
161-
/// or leave this behavior unspecified.
162+
/// or leave this behavior unspecified. This will never
163+
/// reacquire the lock however.
162164
///
163165
/// - Parameter body: A closure with a parameter of `State`
164166
/// that has exclusive access to the value being stored within
@@ -168,9 +170,9 @@ extension Mutex where State: ~Copyable {
168170
///
169171
/// - Returns: The return value, if any, of the `body` closure parameter
170172
/// or nil if the lock couldn't be acquired.
171-
public borrowing func withLockIfAvailable<Result: ~Copyable & Sendable, E: Error>(
172-
_ body: (transferring inout State) throws(E) -> Result?
173-
) throws(E) -> Result?
173+
public borrowing func withLockIfAvailable<Result: ~Copyable, E: Error>(
174+
_ body: (transferring inout State) throws(E) -> transferring Result?
175+
) throws(E) -> transferring Result?
174176
}
175177
```
176178

0 commit comments

Comments
 (0)