When dealing with Future: 'a
one might create a Future: 'static
by moving the borrowed value into async move { ... }
like so:
struct A;
fn foo<'a>(_a: &'a A) -> impl Future<Output=()> + 'a {
async {}
}
fn bar(a: A) -> impl Future<Output=()> + 'static {
async move { foo(&a).await }
}
How to do it with Stream
?
fn sfoo<'a>(_a: &'a A) -> impl Stream<Item=()> + 'a {
empty()
}
fn sbar(a: A) -> impl Stream<Item=()> + 'static {
// What here?
// Tried variations of:
// let mut s = sfoo(&a);
// poll_fn(move |cx| {
// s.poll_next_unpin(cx)
// })
empty()
}