Re:Getting Started with Tokio
by rabidferret on Saturday December 24, 2016 @09:14PM
(#13252520)
Just because a type can be named doesn't mean that returning the named type properly expresses your intent.
The name of said type can get real hairy real fast, as well.
Re:Getting Started with Tokio
by Manishearth on Sunday December 25, 2016 @01:03AM
(#13253167)
Right, but in most cases returning a named type is fine. Usually with futures/iterators I've seen that you end up returning a new custom type that implements the trait, and often it's okay to just name it.
Re:Getting Started with Tokio
by rabidferret on Sunday December 25, 2016 @01:50PM
(#13255008)
I think that's only the case when you are specifically trying to avoid boxing.
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>"