[−][src]Function async_scoped::scope_and_collect
pub unsafe async fn scope_and_collect<'a, T: Send + 'static, R, F: FnOnce(&mut Scope<'a, T>) -> R>(
f: F
) -> (R, Vec<T>)
An asynchronous function that creates a scope and
immediately awaits the stream. The outputs of the
futures are collected as a Vec
and returned along with
the output of the block. 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.