Avoiding heap allocations in (some) async trait methods

As you pointed out, it is possible to avoid heap allocations in async trait methods (using unstable features). However, it pretty much bloats up the syntax, as I said more up in this thread.

Nonetheless, I decided to go that way and to use nameable existential (associated) types. If you're interested, see this post for a use case where each async trait method shouldn't do any unnecessary heap allocations (as I might have a lot of these calls), and how I applied the method.

Thanks again for bringing that up in the first place! :+1: It has been pretty helpful and seems to be usable in practice (if using unstable features is an option).

1 Like