Skip to content

How to call a rust::Fn more than once with context #856

@dtolnay

Description

@dtolnay

Moved from #114 (comment). @jerel

The workaround for now is to pass context through manually via an opaque Rust type.

Is there any way today to repeatedly call the callback from C++ with the same context? The example given works great for a oneshot:

void some_async(
    rust::Fn<void(rust::Box<Context> ctx, double ret)> done,
    rust::Box<Context> ctx) const
{
    done(std::move(ctx), 42.0);
}

but I'm unclear if it's possible today to accomplish this:

    done(std::move(ctx), 42.0);
    done(std::move(ctx), 42.1);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions