Async fn in trait MVP comes to nightly

Async fn in trait MVP comes to nightly:

The async working group is excited to announce that async fn can now be used in traits in the nightly compiler. You can now write code like this:

#![feature(async_fn_in_trait)]

trait Database {
    async fn fetch_data(&self) -> String;
}

impl Database for MyDb {
    async fn fetch_data(&self) -> String { ... }
}

A full working example is available in the playground. There are some limitations we’ll cover, as well as a few known bugs to be worked out, but we think it is ready for some users try. Read on for the specifics.

[—]

Source: Inside Rust Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s