GAT iterator with for_each function


I'm trying to create a streaming/lending iterator trait with a for_each method but there are issues with lifetimes when the implementer of the trait isn't 'static (e.g. if it contains a reference with a non 'static lifetime).

Is there any way to make this example work and/or some insight into why it isn't possible?

Alternative playground for an alternative error.

I feel this should probably be filed as an issue, but haven't really made headway beyond that.


@quinedot thanks for the alternative error which gives some additional information!

I went ahead and filed an issue for this using the playground you posted.

lifetime bound not satisfied for a lending iterator (using generic associated types) with `for_each` method · Issue #91693 · rust-lang/rust · GitHub

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.