Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UncheckedSendable: AsyncSequence #44

Merged
merged 7 commits into from
Oct 14, 2024
Merged

UncheckedSendable: AsyncSequence #44

merged 7 commits into from
Oct 14, 2024

Conversation

stephencelis
Copy link
Member

Currently, a non-sendable sequence cannot be erased to AsyncStream using this library's initializers even if one takes care to traffic it through via nonisolated(unsafe):

nonisolated(unsafe) let nonSendable = nonSendable
AsyncStream(nonSendable)  // 🛑

This conditional conformance acts as a workaround:

AsyncStream(UncheckedSendable(nonSendable))

Ideally folks can stop using our concrete async sequence eraser in favor of any AsyncSequence<Element, Failure>, but this requires a minimum deployment target of iOS 18, so it won't be an option for many people for some time.

Currently, a non-sendable sequence cannot be erased to `AsyncStream`
using this library's initializers even if one takes care to traffic it
through via `nonisolated(unsafe)`:

```swift
nonisolated(unsafe) let nonSendable = nonSendable
AsyncStream(nonSendable)  // 🛑
```

This conditional conformance acts as a workaround:

```swift
AsyncStream(UncheckedSendable(nonSendable))
```

Ideally folks can stop using our concrete async sequence eraser in favor
of `any AsyncSequence<Element, Failure>`, but this requires a minimum
deployment target of iOS 18, so it won't be an option for many people
for some time.
@stephencelis stephencelis merged commit e284ff5 into main Oct 14, 2024
7 checks passed
@stephencelis stephencelis deleted the unchecked-sequence branch October 14, 2024 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants