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
Lifetime dependencies will make this use of iterator a compile-time error.
313
-
Or, as part of implementing data type internals, a nonescapable initializer may depend on a variable that is bound to a value that is only valid within that variable's local scope.
314
-
Subsequent uses of the initialized nonescapable object are exactly as safe or unsafe as it would be to use the variable that the initializer depends at the same point:
315
-
316
-
```swift
317
-
let iterator: Iterator
318
-
do {
319
-
let container =Container(...)
320
-
let buffer = container.buffer
321
-
iterator =Iterator(buffer)
322
-
// `iterator` is safe as long as `buffer` is safe to use.
323
-
}
324
-
use(iterator) // 🛑 'iterator' outlives the source of its dependency
325
-
```
326
-
327
-
Again, lifetime dependencies will make this use of iterator a compile-time error.
328
-
Typically, a pointer is valid for the duration of its variable binding.
329
-
So, in practice, nonescapable value that depends on the pointer to be available within the same scope.
312
+
Lifetime dependencies will make this and similar misuses into compile-time errors.
313
+
This will allow developers to safely define and use values that contain pointers into
314
+
other values, ensuring that the pointers never outlive the underlying storage.
0 commit comments