Can't compile the use of impl AsyncFn
within a spawned thread
#138207
Labels
A-async-closures
`async || {}`
A-diagnostics
Area: Messages for errors, warnings, and lints
D-confusing
Diagnostics: Confusing error or lint that should be reworked.
needs-triage
This issue may need triage. Remove it if it has been sufficiently triaged.
I'm getting the following errors when attempting to use a closure within a spawned thread, the errors are a bit too cryptic for me to understand how to correct the following code.
Error:
Using
impl Fn() -> impl Future
instead ofimpl AsyncFn
then works but for my use case, a mutable closure is needed which blocks me from usingimpl FnMut
because of the following issue:Error:
Essentially,
async || {}
instead of|| async {}
,impl AsyncFnMut
seems to break as soon as it's within a spawned thread which means I'd want to instead try:impl FnMut -> impl Future
,impl FnMut
seems to break the use ofasync || {}
which means I'd want to instead try:|| async {}
,|| async {}
no longer allows me to use a mutable reference which then breaks the required functionalityimpl AsyncFn*
not allowed within spawned threads?async || {}
not be passed to a function that takesimpl FnMut -> impl Future
?The text was updated successfully, but these errors were encountered: