Yield reference in coroutine with GAT #69268
Labels
A-associated-items
Area: Associated items (types, constants & functions)
A-coroutines
Area: Coroutines
A-GATs
Area: Generic associated types (GATs)
C-feature-request
Category: A feature request, i.e: not implemented / a PR.
F-coroutines
`#![feature(coroutines)]`
GATs-triaged
Issues using the `generic_associated_types` feature that have been triaged
T-lang
Relevant to the language team, which will review and decide on the PR/issue.
Since #67160 has been merged in December, having a GAT with lifetimes should be possible (See the
StreamingIterator
example in that PR).The current trait-defition of a coroutine is the following:
The issue here is that the
Yield
can't be parameterized with a lifetime, so yielding a reference from a coroutine is not possible in its current state.By using a GAT for the
Yield
AT, it would be possible to return a local reference.I also don't see why the resume argument type could not have been expressed with a GAT, so at the end we would use the following trait definition for a coroutine:
The text was updated successfully, but these errors were encountered: