Closed Matthias247 closed 2 years ago
I would prefer not to pursue this in this crate, but it would be great if someone else maintained a different crate which works that way.
Thanks anyway for the suggestion, the writeup in the forum thread, and the prototype!
I wrote a bit on internals.rust-lang.org how a different
Future
type could be used to achieve type erasure + dynamic dispatch, while improving performance for some use-cases.By using a specialized
Future
, allocations can for example between reused between various calls to the trait. I think there might also be other possibilities and use-cases.Would you be interested to move
async-trait
to using something likeDynamicFuture
?The type could live in this project, in an independent project, or eventually move into the standard library (it's essentially just another storage agnostic trait object - like
Waker/RawWaker
.I think to answer this question one should also consider the follow-up question of: Could
async-trait
allow to influence the type of generated code via either additional attributes or plugins in order to actually make use of different future representations. But the details about this could be figured out later on in separate discussions.