Skip to content

Commit cfb2ded

Browse files
committed
Mention async/throwing
1 parent 54999f0 commit cfb2ded

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

proposals/NNNN-non-escapable.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,19 +134,21 @@ Copyable or noncopyable types can be escapable or nonescapable.
134134

135135
#### Constraints on nonescapable local variables
136136

137-
A nonescapable value can be freely copied and passed into other functions as long as the usage can guarantee that the value does not persist beyond the current scope:
137+
A nonescapable value can be freely copied and passed into other functions, including async and throwing functions, as long as the usage can guarantee that the value does not persist beyond the current scope:
138138

139139
```swift
140140
// Example: Local variable with nonescapable type
141141
func borrowingFunc(_: borrowing NotEscapable) { ... }
142142
func consumingFunc(_: consuming NotEscapable) { ... }
143143
func inoutFunc(_: inout NotEscapable) { ... }
144+
func asyncBorrowingFunc(_: borrowing NotEscapable) async -> ResultType { ... }
144145

145146
func f() {
146147
var value: NotEscapable
147148
let copy = value // OK to copy as long as copy does not escape
148149
globalVar = value // 🛑 May not assign to global
149150
SomeType.staticVar = value // 🛑 May not assign to static var
151+
async let r = asyncBorrowingFunc(value) // OK to pass borrowing
150152
borrowingFunc(value) // OK to pass borrowing
151153
inoutFunc(&value) // OK to pass inout
152154
consumingFunc(value) // OK to pass consuming

0 commit comments

Comments
 (0)