You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -184,7 +184,7 @@ Of course, an optional is of limited use unless we are able to decide whether it
184
184
```
185
185
186
186
- The optional chaining special form `?`:
187
-
187
+
188
188
```swift
189
189
funccount(ofmaybeSpan: Span<Int>?) ->Int {
190
190
guardlet c = maybeSpan?.countelse { return0 }
@@ -200,7 +200,7 @@ Of course, an optional is of limited use unless we are able to decide whether it
200
200
return span.count
201
201
}
202
202
```
203
-
203
+
204
204
These variants all work as expected. To avoid escapability violations, unwrapping the nonescapable optional results in a value with precisely the same lifetime dependencies as the original optional value. This applies to all forms of unwrapping, including pattern matching forms that bind copies of associated values to new variables, like `let span` above -- the resulting `span` value always has the same lifetime as the optional it comes from.
205
205
206
206
The standard `Optional` type has custom support for comparing optional instances against `nil` using the traditional `==` operator, whether or not the wrapped type conforms to `Equatable`. [SE-0437] generalized this mechanism for noncopyable wrapped types, and it is reasonable to extend this to also cover the nonescapable case:
0 commit comments