Re:Why async fn in traits are hard
by Rusky on Sunday October 27, 2019 @02:26PM
(#21371508)
In that particular example you won't get boxes of boxes- `baz` gets instantiated for each impl of `Baz`, so the call to `self.foo()` is resolved statically and the return type is fully known.
[ Parent
| on HN ]
Depends on the (not-yet-implemented) implementation of async functions in traits. But currently, with the async_trait macro, there is only one version of Foo::foo, and it returns a Box<...>.
But it is true we could imagine the compiler generating two versions: one for when the static type is known, and one if dynamic dispatch is used.