Skip to content

Commit 1bb969f

Browse files
committed
Actually, the async gen troubles aren't anything beyond the self-referential gen block issues
1 parent e07b766 commit 1bb969f

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

text/0000-gen-fn.md

+9-4
Original file line numberDiff line numberDiff line change
@@ -350,17 +350,22 @@ as there are many more open questions around them than around just a simpler way
350350

351351
## `async` interactions
352352

353-
We could support using `await` in `gen` blocks, similar to how we support `?` being used within them.
354-
This is not trivially possible due to the fact that `Iterator::next` takes `&mut self` and not `Pin<&mut self>`.
353+
We could support using `await` in `async gen` blocks, similar to how we support `?` being used within `gen` blocks.
354+
This is not possible in general due to the fact that `Iterator::next` takes `&mut self` and not `Pin<&mut self>`, but
355+
it should be possible if no references are held across the `await` point, similar to how we disallow holding
356+
references across `yield` points in this RFC.
355357

356-
There are a few options forward for this:
358+
359+
## self-referential `gen` bloocks
360+
361+
There are a few options forward:
357362

358363
* Add a separate trait for pinned iteration that is also usable with `gen` and `for`
359364
* downside: very similar traits for the same thing
360365
* backwards compatibly add a way to change the argument type of `Iterator::next`
361366
* downside: unclear if possible
362367
* implement `Iterator` for `Pin<&mut G>` instead of for `G` directly (whatever `G` is here, but it could be a `gen` block)
363-
* downside: the thing being iterated over must now be pinned for the entire iteration, instead of for each iteration
368+
* downside: the thing being iterated over must now be pinned for the entire iteration, instead of for each invocation of `next`.
364369

365370
## `try` interactions
366371

0 commit comments

Comments
 (0)