existential Generator + lifetime type errors unless impl trait wrapper is used #58662
Labels
A-impl-trait
Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.
E-needs-test
Call for participation: An issue has been fixed and does not reproduce, but no test has been added.
F-type_alias_impl_trait
`#[feature(type_alias_impl_trait)]`
requires-nightly
This issue requires a nightly compiler in some way.
I'm writing a simple Generator that takes a reference to an RNG, and yields values from it. This makes sense as long as the generator doesn't outlive the RNG which it references.
I want to name the type of the generator with an existential type, but I can't do so unless I wrap a version of the function that uses an
impl Trait
formulation.Here's the direct version which doesn't work
and here's the more convoluted version which does
and here's a playground link containing both versions, as well as a bit of scaffolding
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=7c7b6ce96c2f1b7d5d4a4c3d2d65a33f
The full error message I'm seeing looks like this
The text was updated successfully, but these errors were encountered: