Skip to content

can't move variable into closure in special case #86709

Closed
@FH0

Description

@FH0
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.
image

I checked a lot of information but still can't solve it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions