dtolnay / async-trait

Type erasure for async trait methods
Apache License 2.0
1.81k stars 84 forks source link

The status of GAT implementation? #220

Closed JakkuSakura closed 1 year ago

JakkuSakura commented 1 year ago

Hi,

Since GAT is now stabilized, what's the status of GAT of async_trait?

I'm building a library that utilizes GAT heavily. It will be nice just write

#[async_trait]
trait Foo {
    async fn foo(&self);
}
struct F;
#[async_trait]
trait Foo {
    async fn foo(&self) {}
}

Rather than

trait Foo {
    type Future<'a>: Future<Output = ()> + 'a;
    fn foo(&self) -> self::Future<'_>;
}
struct F;
trait Foo {
    type Future<'a> = impl Future<Output = ()> + 'a;
    fn foo(&self) -> self::Future<'_> {}
}

GAT can eliminate Boxes, but harder to write and not object-safe. So it's better to have an option to opt-in the GAT version.

dtolnay commented 1 year ago

A GAT implementation is not being considered for this crate.

vikulikov commented 1 year ago

A GAT implementation is not being considered for this crate.

But why?