Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async traits implementation from nightly #17

Closed
Niederb opened this issue Apr 13, 2023 · 5 comments
Closed

Async traits implementation from nightly #17

Niederb opened this issue Apr 13, 2023 · 5 comments

Comments

@Niederb
Copy link
Contributor

Niederb commented Apr 13, 2023

This crate currently uses the async_trait crate to support async functions in traits.
My understanding of async is not very deep but I wonder if it would be possible to use the implementation that is available on nightly instead? (see https://blog.rust-lang.org/inside-rust/2022/11/17/async-fn-in-trait-nightly.html)

@fMeow
Copy link
Owner

fMeow commented Apr 14, 2023

This is indeed posiible. However the async fn in trait RFC is still in early development and not stablized yet, so I think it more appropriate to add a feature gate to do so.

@dtolnay
Copy link
Contributor

dtolnay commented Jan 15, 2024

@fMeow
Copy link
Owner

fMeow commented Jan 30, 2024

Working on this.

@fMeow
Copy link
Owner

fMeow commented Jan 31, 2024

I released 0.2.9 which add async fn in traits support. For compatibilty reason, a AFIT flag is used to indicate a native async fn in traits. So the api is like the following:

#[maybe_async::maybe_async(AFIT)]
trait A {
    async fn async_fn_in_trait() -> Result<(), ()>;
}

struct Foo;

#[maybe_async::maybe_async(AFIT)]
impl A for Foo {
    async fn async_fn_in_trait() -> Result<(), ()> {
        Ok(())
    }
}

It will become the default in the future major release, but not for now.

@fMeow
Copy link
Owner

fMeow commented Feb 2, 2024

Close as solved in 0.2.9.

@fMeow fMeow closed this as completed Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants