Closed
Description
use futures::Future;
use tokio::sync::mpsc::channel;
fn foo<F, S>(mut f: F)
where
F: FnMut() -> S,
S: Future,
{
f();
}
#[tokio::main]
async fn main() {
let (tx, mut rx) = channel::<bool>(1);
foo(move || async move {
let _ = rx.recv().await;
});
}
I want to move rx into closure but failed.
I checked a lot of information but still can't solve it.
- https://github.com/hyperium/hyper/blob/master/examples/http_proxy.rs#L30-#L33
- Cannot assign to captured outer variable in an
FnMut
closure diagnostic #41790 - https://stackoverflow.com/questions/53038935/cannot-move-out-of-captured-variables-in-an-fnmut-closure
- https://docs.rs/hyper/0.14.9/hyper/service/fn.service_fn.html
Metadata
Metadata
Assignees
Labels
No labels