Closed Verdagon closed 2 years ago
Temporary workaround shown in https://github.com/Verdagon/RustFearlessStructuredConcurrency/blob/1734c0a7a2fe779390941a3bfe90e33efc698dfa/src/main.rs
TL;DR: instead of: Scope::scope_and_block(|s| { ...
do:
Scope::scope_and_block(|s: &mut async_scoped::Scope<'_, (), async_scoped::spawner::use_async_std::AsyncStd>| { ...
This does require a change to async-scoped source code though, to make spawner
public. Specifically, in async-scoped/src/lib.rs, change mod spawner;
to pub mod spawner;
.
The inference failure is intended as Scope
is the general structure that supports both async-std and tokio. To use async-std, make sure you have enabled the use-async-std
feature of the crate, and use AsyncScope
instead of Scope
. Pls. refer example in the docs: https://docs.rs/async-scoped/latest/async_scoped/#scope-api
That solved it! I'm not sure how I missed that, it felt like I'd tried everything at the time.
Thank you for your help!
If I compile the example program, the compiler fails to infer the closure's type:
(reproduced in https://github.com/Verdagon/RustFearlessStructuredConcurrency/blob/33019c43cd95d5ad2152590263739549d38ab869/src/main.rs)