Skip to content

Support for async closure #94

@not-elm

Description

@not-elm

Since Rust 2024 edition, We can use async-closures withAsyncFn* traits.
By using this feature, we will be able to write code like the example below.

Reactor::schedule(async move |task|{

});

However, the future returned by the closure cannot be made thread-safe, which makes the implementation difficult (it is technically doable if you use an unsafe impl, though).

    #[inline(always)]
    pub fn schedule<F>(f: F) -> Scheduler<State>
    where
        F: AsyncFnOnce(CoreTask<State>) + Send + Sync + 'static,
        <F as AsyncFnOnce<(CoreTask<State>,)>>::CallOnceFuture: Send + Sync,
       ---------------------------------------------- expected 1 generic argument

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions