[−][src]Function async_scoped::scope_and_iterate
pub unsafe async fn scope_and_iterate<'a, T: Send + 'static, R, F: FnOnce(&mut Scope<'a, T>) -> R, G: FnMut(T) -> H, H: Future<Output = ()>>(
f: F,
g: G
) -> R
An asynchronous function that creates a scope and
immediately awaits the stream, and sends it through an
FnMut (using futures::StreamExt::for_each
). It takes
two args, the first that spawns the futures, and the
second is the function to call on the stream. This macro
must be invoked within an async block.
Safety
This macro is not completely safe: please see https://www.reddit.com/r/rust/comments/ee3vsu/asyncscoped_spawn_non_static_futures_with_asyncstd/fbpis3c?utm_source=share&utm_medium=web2x The caller must ensure the enclosing async block (and it's stack) does not collapse before the macro completes driving the stream. However, unless the enclosing future gets forgotten, the implementation will still panic when the returned future is dropped without being fully driven.