4lDO2/real-async-trait-rs

Is impl trait alias really necessary?

dignifiedquire opened this issue · 2 comments

I was wondering what part currently fails if removing the type alias, as that could potentially bring us to stable rust, with GATs now stabilized.

4lDO2 commented

The implementation block for the trait needs to specify the actual types the GATs will have for that impl. An async block will have an anonymous type, so you need impl trait as you would have to write the future yourself otherwise (or box the underlying future, which is what async-trait does). It could be possible to use this crate on stable to only define the trait under a Cargo feature, but I'm not sure when this crate will become obsolete, since async_fn_in_trait is already available on nightly.

thanks for the explanation