-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Yield reference in coroutine with GAT #69268
Copy link
Copy link
Open
Labels
A-GATsArea: Generic associated types (GATs)Area: Generic associated types (GATs)A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-coroutinesArea: CoroutinesArea: CoroutinesC-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.F-coroutines`#![feature(coroutines)]``#![feature(coroutines)]`T-langRelevant to the language teamRelevant to the language teamT-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-GATsArea: Generic associated types (GATs)Area: Generic associated types (GATs)A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-coroutinesArea: CoroutinesArea: CoroutinesC-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.F-coroutines`#![feature(coroutines)]``#![feature(coroutines)]`T-langRelevant to the language teamRelevant to the language teamT-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Since #67160 has been merged in December, having a GAT with lifetimes should be possible (See the
StreamingIteratorexample in that PR).The current trait-defition of a coroutine is the following:
The issue here is that the
Yieldcan'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
YieldAT, 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: