Getting Started with Tokio(lukesteensen.com) |
Getting Started with Tokio(lukesteensen.com) |
Thank you for the whole team.
What is the reason to box the futures? futures::finished and futures::failed both return FutureResult.
(I haven't dug into the specifics of this specific example; that's what I assumed when I read that line. Maybe the author also knew this rule of thumb and did it unnecessarily...)
E.g. in this case there's no specific compulsion to use a trait object.
I wouldn't consider this to be a rule of thumb; it's more like "if you have trouble naming the return type try using Box<Trait>"
Can someone point me to more info on this? Possibly akin to existential types in Haskell?
The difference between trait objects and `impl Trait` is that trait objects can hold any value that implements a trait, since they're implemented via dynamic dispatch.
The name of said type can get real hairy real fast, as well.